Agent Executor (AX) is Google's open agentic orchestration runtime
Go
Introduction of task executor (#91)
Jaana Dogan7554465a1c81
diff --git a/.gitignore b/.gitignoreindex b7fd4f7..5b1f68b 100644--- a/.gitignore+++ b/.gitignore@@ -10,3 +10,4 @@ google-cloud-sdk/test-sandbox-config.yamlsandbox-routerexamples/sandbox_agent/cloudbuild.yaml+tasklog/*\ No newline at end of filediff --git a/Makefile b/Makefileindex 573a313..9d6ca73 100644--- a/Makefile+++ b/Makefile@@ -61,3 +61,8 @@ deps:build-router:@echo "Building sandbox-router Linux binary..."@GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o sandbox-router ./cmd/sandbox-router++clean-logs:+ @echo "Cleaning the event logs..."+ rm -rf ./eventlog+ mkdir ./eventlogdiff --git a/README.md b/README.mdindex d91731c..e7f95b1 100644--- a/README.md+++ b/README.md@@ -74,6 +74,12 @@ You can continue a session any time:gar trigger --session session123 --input "Show me the contents of README.md"```+Instead of running the default planner agent, you can run any registered agent:++```bash+gar trigger --agent coding --input "Can you list me this directory?"+```+### 2. Run Remote Agent with GAR ServerMost developers want to register their custom remote agents.@@ -123,6 +129,7 @@ The `gar` command provides several subcommands:gar trigger \--input <text> \[--session <id>] \+ [--agent <id>] \[--server <address>] \[--config <file>]```@@ -132,6 +139,7 @@ Triggers a new agentic loop session or automatically resumes an existing one. IfOptions:- `--input`: Input message to send to agents (required)- `--session`: Unique session identifier (optional, generates UUID if not provided, or resumes if exists)+- `--agent`: Agent ID to use for the session (optional, defaults to planner)- `--server`: gRPC controller server address (optional. If not provided, runs with a built-in GAR server)- `--config`: Path to YAML configuration file (only used with a built-in GAR server, default: "gar.yaml")@@ -147,6 +155,7 @@ gar trigger --session abc123 --input "Ok, now let's do something else..."# Trigger using server mode (connect to gar serve)gar trigger --server localhost:8494 --input "Hello agents!"+gar trigger --agent coding --input "Hello coding agent, write me a cool Go program!"```#### Fork a Session@@ -217,14 +226,20 @@ server:eventlog:dir: "eventlog"-# Maximum steps per trigger-max_steps: 5-health_check:- # Health check interval for agents+ enabled: trueinterval: 30s-# Agents to register on startup+planner:+ gemini:+ model: "gemini-3-flash-preview"+ temperature: 0.7+ max_tokens: 8192+ timeout: 60s+ context_window: 30+ system_prompt: "..."+ skills_dir: "./examples/skills"+registry:remote_agents:- id: "remote-text-processor"@@ -289,6 +304,10 @@ The built-in planner is equipped with a `bash` tool that enables it to execute gFor safety and control, any execution initiated by the bash tool requires explicit user approval via a confirmation flow before running.+### Gemini Agent++GAR includes a built-in Gemini agent that can be used to generate text based on a given prompt. The agent is registered as `gemini`.+## Building Custom Agents### Local Agent@@ -380,9 +399,10 @@ Ensure your `gar.yaml` references this sandbox agent:```yamlregistry:k8s_sandbox_agents:- - id: "uppercase-agent"+ - id: "uppercase"sandbox_template_ref: "uppercase-agent-template"container_port: 8494+ use_router: true```**4. Run the GAR Server**@@ -393,7 +413,7 @@ gar serve --config gar.yaml**5. Trigger the Agent**In a separate terminal:```bash-gar trigger --input "use the uppercase-agent to convert 'hello world'"+gar trigger --input "use the uppercase agent to convert 'hello world'"```The system will dynamically create a `SandboxClaim`, establish a connection via `kubectl port-forward`, execute the code securely, and return the result.diff --git a/agent/agent.go b/agent/agent.goindex e4e5461..f1b6ac3 100644--- a/agent/agent.go+++ b/agent/agent.go@@ -20,19 +20,32 @@ import ("context""github.com/google/gar/proto"+ "google.golang.org/protobuf/types/known/anypb")// OutputHandler is a callback function that handles output content from an agent.// It is called for each piece of content the agent generates.type OutputHandler func(outgoing *proto.ProcessResponse) error+type Task struct {+ ID string+ AgentID string+ Inputs []*proto.Content+ Rehydrate bool+ Config *anypb.Any // agent implementation specific configuration+}++type TaskExecutor interface {+ Exec(ctx context.Context, t *Task, o OutputHandler) error+}+// Agent defines the common interface for both local and remote agents.// Agents process content using callback handlers.type Agent interface {// Process handles processing of input content.// It calls the output handler for each piece of content generated.// The handler may be called multiple times during processing.- Process(ctx context.Context, sessionID string, incoming *proto.ProcessRequest, handler OutputHandler) error+ Process(ctx context.Context, t *Task, e TaskExecutor, o OutputHandler) error// HealthCheck checks if the agent is healthy and responsive.// Returns an error if the agent is unhealthy or unreachable.diff --git a/agent/k8s_sandbox.go b/agent/k8s_sandbox.goindex 65339e9..223f186 100644--- a/agent/k8s_sandbox.go+++ b/agent/k8s_sandbox.go@@ -25,7 +25,6 @@ import ("time""github.com/google/gar/internal/sandboxclient"- "github.com/google/gar/proto""google.golang.org/grpc/metadata")@@ -82,10 +81,13 @@ func (a *KubernetesSandboxAgent) HealthCheck(ctx context.Context) error {return nil}-func (a *KubernetesSandboxAgent) Process(ctx context.Context, sessionID string, req *proto.ProcessRequest, handler OutputHandler) error {+func (a *KubernetesSandboxAgent) Process(ctx context.Context, t *Task, e TaskExecutor, o OutputHandler) error {+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)+ defer cancel()+// Use the sessionID deterministically so interactive sessions reuse the same sandbox pod,// rather than spawning a new pod for every exchanged message.- safeSessionID := strings.ReplaceAll(sessionID, "-", "")+ safeSessionID := strings.ReplaceAll(t.ID, "-", "")if len(safeSessionID) > 20 {safeSessionID = safeSessionID[:20] // Keep it short for k8s names}@@ -196,7 +198,7 @@ func (a *KubernetesSandboxAgent) Process(ctx context.Context, sessionID string,defer remoteAgent.Close()// Forward the request!- return remoteAgent.Process(ctx, sessionID, req, handler)+ return remoteAgent.Process(ctx, t, e, o)}func findAvailablePort() (int, error) {diff --git a/agent/local.go b/agent/local.goindex cfc335e..e01dd2b 100644--- a/agent/local.go+++ b/agent/local.go@@ -17,20 +17,18 @@ package agentimport ("context""fmt"-- "github.com/google/gar/proto")// LocalAgent wraps a local (in-process) agent implementation.// It implements the Agent interface for agents running in the same process as the controller.type LocalAgent struct {- processFunc func(ctx context.Context, sessionID string, incoming *proto.ProcessRequest, handler OutputHandler) error+ processFunc func(ctx context.Context, t *Task, e TaskExecutor, o OutputHandler) errorhealthCheckFunc func(ctx context.Context) error}// LocalAgentConfig configures a local agent.type LocalAgentConfig struct {- ProcessFunc func(ctx context.Context, sessionID string, incoming *proto.ProcessRequest, handler OutputHandler) error+ ProcessFunc func(ctx context.Context, t *Task, e TaskExecutor, o OutputHandler) errorHealthCheckFunc func(ctx context.Context) error}@@ -52,8 +50,8 @@ func NewLocalAgent(config LocalAgentConfig) (*LocalAgent, error) {}// Process handles processing of input content with callback handler.-func (a *LocalAgent) Process(ctx context.Context, sessionID string, incoming *proto.ProcessRequest, handler OutputHandler) error {- return a.processFunc(ctx, sessionID, incoming, handler)+func (a *LocalAgent) Process(ctx context.Context, t *Task, e TaskExecutor, o OutputHandler) error {+ return a.processFunc(ctx, t, e, o)}// HealthCheck checks if the agent is healthy.diff --git a/agent/remote.go b/agent/remote.goindex 6fab77e..2a10abb 100644--- a/agent/remote.go+++ b/agent/remote.go@@ -94,9 +94,9 @@ func (a *RemoteAgent) connect() error {}// Process handles processing of input content with the remote agent.-func (a *RemoteAgent) Process(ctx context.Context, sessionID string, incoming *proto.ProcessRequest, handler OutputHandler) error {+func (a *RemoteAgent) Process(ctx context.Context, t *Task, e TaskExecutor, o OutputHandler) error {// Add session_id to gRPC metadata without overwriting existing metadata hooks (e.g. sandbox routers)- ctx = metadata.AppendToOutgoingContext(ctx, "session-id", sessionID)+ ctx = metadata.AppendToOutgoingContext(ctx, "session-id", t.ID)stream, err := a.client.Process(ctx)if err != nil {@@ -104,10 +104,7 @@ func (a *RemoteAgent) Process(ctx context.Context, sessionID string, incoming *p}// Send all inputs to the remote agent- if err := stream.Send(&proto.ProcessRequest{- CheckpointId: incoming.CheckpointId,- Contents: incoming.Contents,- }); err != nil {+ if err := stream.Send(&proto.ProcessRequest{Contents: t.Inputs}); err != nil {return fmt.Errorf("failed to send content: %w", err)}@@ -128,7 +125,7 @@ func (a *RemoteAgent) Process(ctx context.Context, sessionID string, incoming *p}// Call the handler with the received content- if err := handler(resp); err != nil {+ if err := o(resp); err != nil {return fmt.Errorf("handler error: %w", err)}diff --git a/cmd/gar/serve.go b/cmd/gar/serve.goindex d013f1d..303795c 100644--- a/cmd/gar/serve.go+++ b/cmd/gar/serve.go@@ -20,12 +20,13 @@ import ("log""os""os/signal"+ "path""syscall""github.com/google/gar/agent""github.com/google/gar/internal/config""github.com/google/gar/internal/controller"- "github.com/google/gar/internal/eventlog"+ "github.com/google/gar/internal/controller/task""github.com/google/gar/internal/server""github.com/spf13/cobra")@@ -89,11 +90,9 @@ func runServe(cmd *cobra.Command, args []string) error {func newControllerFromConfig(ctx context.Context, cfg *config.Config) (*controller.Controller, error) {// Create event log builder- eventLogBuilder := func(sessionID string) (eventlog.EventLog, error) {- return eventlog.NewFileEventLog(eventlog.FileConfig{- SessionID: sessionID,- Dir: cfg.EventLog.Dir,- })+ eventLogBuilder := func(taskID string) (task.EventLog, error) {+ path := path.Join(cfg.EventLog.Dir, taskID+".jsonl")+ return task.OpenFileEventLog(path)}// Create planner builder@@ -102,12 +101,14 @@ func newControllerFromConfig(ctx context.Context, cfg *config.Config) (*controll// Currently, it uses the Gemini planner.// Gemini config can be customized via environment variables (GEMINI_API_KEY, GAR_GEMINI_MODEL)// TODO(lhuan): allow other planners based on cfg.PlannerType- return controller.NewGeminiPlanner(ctx, r, controller.GeminiPlannerConfig{- Model: cfg.Planner.Gemini.Model,- MaxTokens: cfg.Planner.Gemini.MaxTokens,- Timeout: cfg.Planner.Gemini.Timeout,- SystemPrompt: cfg.Planner.Gemini.SystemPrompt,- SkillsDir: cfg.Planner.Gemini.SkillsDir,+ return controller.NewGeminiPlannerAgent(ctx, r, controller.GeminiPlannerConfig{+ GeminiConfig: controller.GeminiConfig{+ Model: cfg.Planner.Gemini.Model,+ MaxTokens: cfg.Planner.Gemini.MaxTokens,+ Timeout: cfg.Planner.Gemini.Timeout,+ SystemPrompt: cfg.Planner.Gemini.SystemPrompt,+ },+ SkillsDir: cfg.Planner.Gemini.SkillsDir,})}@@ -115,7 +116,6 @@ func newControllerFromConfig(ctx context.Context, cfg *config.Config) (*controllcontrollerConfig := controller.Config{EventLogBuilder: eventLogBuilder,PlannerBuilder: plannerBuilder,- MaxSteps: cfg.MaxSteps,HealthCheck: cfg.HealthCheck,}diff --git a/cmd/gar/trigger.go b/cmd/gar/trigger.goindex 760e124..1e6ce37 100644--- a/cmd/gar/trigger.go+++ b/cmd/gar/trigger.go@@ -33,6 +33,7 @@ import (var (triggerSessionID string+ triggerAgentID stringtriggerInput stringtriggerServerAddr stringtriggerConfigFile string@@ -48,6 +49,7 @@ If no session ID is provided, a new UUID will be generated.`,func init() {triggerCmd.Flags().StringVar(&triggerSessionID, "session", "", "Session ID (optional, generates UUID if not provided)")+ triggerCmd.Flags().StringVar(&triggerAgentID, "agent", "", "Agent ID (optional, planner is used if not specified)")triggerCmd.Flags().StringVar(&triggerInput, "input", "", "Input message to send (optional)")triggerCmd.Flags().StringVar(&triggerServerAddr, "server", "", "gRPC controller server address (if specified, connects to remote server; otherwise runs with a local built-in GAR server)")triggerCmd.Flags().StringVar(&triggerConfigFile, "config", "gar.yaml", "Path to YAML configuration file (only used with a local built-in GAR server)")@@ -83,10 +85,10 @@ func runTrigger(cmd *cobra.Command, args []string) error {cancel()}()- return triggerLoop(ctx, triggerSessionID, triggerInput)+ return triggerLoop(ctx, triggerSessionID, triggerAgentID, triggerInput)}-func triggerLoop(ctx context.Context, sessionID string, input string) error {+func triggerLoop(ctx context.Context, sessionID string, agentID string, input string) error {d := internal.NewDisplay(sessionID)d.DisplayHeader()@@ -99,7 +101,7 @@ func triggerLoop(ctx context.Context, sessionID string, input string) error {}d.DisplayInput(input)- inputs := []*proto.Content{+ history := []*proto.Content{{Role: "user",Content: &proto.Content_Text{@@ -111,83 +113,110 @@ func triggerLoop(ctx context.Context, sessionID string, input string) error {}for {- var conf *proto.ConfirmationContent- var err error- if triggerServerAddr == "" {- conf, err = runTriggerHeadless(ctx, d, triggerSessionID, inputs)- } else {- conf, err = runTriggerServer(ctx, d, triggerSessionID, inputs)- }+ conf, outputs, err := runAutoTrigger(ctx, d, sessionID, agentID, history)if err != nil {return err}+ history = append(history, outputs...)if conf != nil {- approved, err := d.PromptForApproval(conf.Question)- if err != nil {- return err- }- if approved {- inputs = []*proto.Content{{- Role: "user",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: conf.Id,- Decision: &proto.ConfirmationContent_Approval{- Approval: &proto.ApprovalDecision{Approved: true},+ for {+ approved, err := d.PromptForApproval(conf.Question)+ if err != nil {+ return err+ }+ var decision []*proto.Content+ if approved {+ decision = []*proto.Content{{+ Role: "user",+ Content: &proto.Content_Confirmation{+ Confirmation: &proto.ConfirmationContent{+ Id: conf.Id,+ Decision: &proto.ConfirmationContent_Approval{+ Approval: &proto.ApprovalDecision{Approved: true},+ },},},- },- }}- } else {- inputs = []*proto.Content{{- Role: "user",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: conf.Id,- Decision: &proto.ConfirmationContent_Decline{- Decline: &proto.DeclineDecision{Declined: true},+ }}+ } else {+ decision = []*proto.Content{{+ Role: "user",+ Content: &proto.Content_Confirmation{+ Confirmation: &proto.ConfirmationContent{+ Id: conf.Id,+ Decision: &proto.ConfirmationContent_Decline{+ Decline: &proto.DeclineDecision{Declined: true},+ },},},- },- }}+ }}+ }+ // The task is still pending, we need to only send the answer.+ // not the full history. Because we executor will put the full+ // history together.+ conf, outputs, err = runAutoTrigger(ctx, d, sessionID, agentID, decision)+ if err != nil {+ return err+ }+ history = append(history, decision...)+ history = append(history, outputs...)+ if conf == nil {+ break+ }}- continue}+ // Once we finished a task, we should start another one+ // to continue the conversation with history.+ sessionID = uuid.NewString()+ d := internal.NewDisplay(sessionID)+ d.DisplayHeader()++ // Remove all the function calls, confirmations,+ // and function responses. They are not relevant+ // for the upcoming executions.+ history = resetHistory(history)+input, err = d.PromptForInput()if err != nil {return err}d.DisplayInput(input)- inputs = []*proto.Content{- {- Role: "user",- Content: &proto.Content_Text{- Text: &proto.TextContent{- Text: input,- },+ history = append(history, &proto.Content{+ Role: "user",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: input,},},- }+ })}}-func runTriggerHeadless(ctx context.Context, d *internal.Display, sessionID string, inputs []*proto.Content) (*proto.ConfirmationContent, error) {+func runAutoTrigger(ctx context.Context, d *internal.Display, sessionID string, agentID string, inputs []*proto.Content) (*proto.ConfirmationContent, []*proto.Content, error) {+ fn := runTriggerHeadless+ if triggerServerAddr != "" {+ fn = runTriggerServer+ }+ return fn(ctx, d, sessionID, agentID, inputs)+}++func runTriggerHeadless(ctx context.Context, d *internal.Display, sessionID string, agentID string, inputs []*proto.Content) (*proto.ConfirmationContent, []*proto.Content, error) {if triggerController == nil {cfg, err := config.LoadFromFile(triggerConfigFile)if err != nil {- return nil, fmt.Errorf("error loading config file '%s': %w", triggerConfigFile, err)+ return nil, nil, fmt.Errorf("error loading config file '%s': %w", triggerConfigFile, err)}c, err := newControllerFromConfig(ctx, cfg)if err != nil {- return nil, fmt.Errorf("error creating controller: %w", err)+ return nil, nil, fmt.Errorf("error creating controller: %w", err)}triggerController = c}var checkpoint string+ var outputs []*proto.Contentvar confirmation *proto.ConfirmationContentoutputHandler := agent.OutputHandler(func(resp *proto.ProcessResponse) error {if resp.CheckpointId != "" {@@ -199,39 +228,41 @@ func runTriggerHeadless(ctx context.Context, d *internal.Display, sessionID striconfirmation = conf}}-+ outputs = append(outputs, resp.Contents...)displayContents(d, resp.Contents)return nil})- if err := triggerController.TriggerSession(ctx, sessionID, &proto.ProcessRequest{+ if err := triggerController.TriggerSession(ctx, sessionID, agentID, &proto.ProcessRequest{Contents: inputs,}, outputHandler); err != nil {- return nil, fmt.Errorf("error triggering session with local server: %w", err)+ return nil, nil, fmt.Errorf("error triggering session with local server: %w", err)}if confirmation == nil {d.FinishOutput(checkpoint)}- return confirmation, nil+ return confirmation, outputs, nil}-func runTriggerServer(ctx context.Context, d *internal.Display, sessionID string, inputs []*proto.Content) (*proto.ConfirmationContent, error) {+func runTriggerServer(ctx context.Context, d *internal.Display, sessionID string, agentID string, inputs []*proto.Content) (*proto.ConfirmationContent, []*proto.Content, error) {conn, err := connect(triggerServerAddr)if err != nil {- return nil, err+ return nil, nil, err}defer conn.Close()client := proto.NewGARServiceClient(conn)stream, err := client.TriggerSession(ctx, &proto.TriggerSessionRequest{SessionId: sessionID,+ AgentId: agentID,Inputs: inputs,})if err != nil {- return nil, fmt.Errorf("error triggering session: %w", err)+ return nil, nil, fmt.Errorf("error triggering session: %w", err)}var checkpoint string+ var outputs []*proto.Contentvar confirmation *proto.ConfirmationContentfor {resp, err := stream.Recv()@@ -239,7 +270,7 @@ func runTriggerServer(ctx context.Context, d *internal.Display, sessionID stringbreak}if err != nil {- return nil, fmt.Errorf("error receiving response: %w", err)+ return nil, nil, fmt.Errorf("error receiving response: %w", err)}if resp.Outputs != nil {for _, c := range resp.Outputs {@@ -247,16 +278,14 @@ func runTriggerServer(ctx context.Context, d *internal.Display, sessionID stringconfirmation = conf}}+ outputs = append(outputs, resp.Outputs...)displayContents(d, resp.Outputs)}- if resp.CheckpointId != "" {- checkpoint = resp.CheckpointId- }}if confirmation == nil {d.FinishOutput(checkpoint)}- return confirmation, nil+ return confirmation, outputs, nil}func displayContents(d *internal.Display, contents []*proto.Content) {@@ -279,3 +308,20 @@ func displayContents(d *internal.Display, contents []*proto.Content) {}}}++func resetHistory(history []*proto.Content) []*proto.Content {+ var out []*proto.Content+ for _, c := range history {+ if c.GetFunctionCall() != nil {+ continue+ }+ if c.GetFunctionResponse() != nil {+ continue+ }+ if c.GetConfirmation() != nil {+ continue+ }+ out = append(out, c)+ }+ return out+}diff --git a/gar.yaml b/gar.yamlindex cfaaba9..0bb9ce0 100644--- a/gar.yaml+++ b/gar.yaml@@ -22,9 +22,6 @@ eventlog:# Directory where event logs are storeddir: "eventlog"-# Maximum number of steps per trigger-max_steps: 5-health_check:# Whether to enable active health checkingenabled: truediff --git a/go.mod b/go.modindex 9939cd5..c85e785 100644--- a/go.mod+++ b/go.mod@@ -8,6 +8,7 @@ require (github.com/google/uuid v1.6.0github.com/spf13/cobra v1.10.2golang.org/x/net v0.48.0+ golang.org/x/sync v0.19.0google.golang.org/genai v1.43.0google.golang.org/grpc v1.78.0google.golang.org/protobuf v1.36.11diff --git a/internal/config/config.go b/internal/config/config.goindex 03dcb27..4e379c0 100644--- a/internal/config/config.go+++ b/internal/config/config.go@@ -28,7 +28,6 @@ import (type Config struct {Server ServerConfig `yaml:"server"`EventLog EventLogConfig `yaml:"eventlog"`- MaxSteps int `yaml:"max_steps"` // Maximum steps per triggerHealthCheck HealthCheckConfig `yaml:"health_check"`Planner PlannerConfig `yaml:"planner,omitempty"`Registry RegistryConfig `yaml:"registry,omitempty"`@@ -137,10 +136,6 @@ func (c *Config) setDefaults() {c.EventLog.Dir = "eventlog"}- // Controller defaults- if c.MaxSteps == 0 {- c.MaxSteps = 5- }// HealthCheck defaultsif c.HealthCheck.Enabled && c.HealthCheck.Interval == 0 {c.HealthCheck.Interval = 30 * time.Second@@ -155,10 +150,6 @@ func (c *Config) Validate() error {if c.EventLog.Dir == "" {return fmt.Errorf("eventlog.dir is required")}- if c.MaxSteps <= 0 {- return fmt.Errorf("max_steps must be positive")- }-// Validate health checkif c.HealthCheck.Enabled {if c.HealthCheck.Interval <= 0 {diff --git a/internal/controller/controller.go b/internal/controller/controller.goindex f8c4318..bd756f6 100644--- a/internal/controller/controller.go+++ b/internal/controller/controller.go@@ -19,22 +19,27 @@ package controllerimport ("context""fmt"+ "os"+ "path""sync""github.com/google/gar/agent""github.com/google/gar/internal/config"- "github.com/google/gar/internal/eventlog"+ "github.com/google/gar/internal/controller/task"+ "github.com/google/gar/internal/testagent""github.com/google/gar/proto")+const plannerAgentID = "__planner"+// Controller is the main controller that coordinates all components.// It acts as a single-writer system for managing agentic loops.type Controller struct {inFlightSessionsMu sync.MutexinFlightSessions map[string]struct{}- sessionManager *SessionManagerregistry *Registry- loopExecutor *LoopExecutor+ eventLogBuilder task.EventLogBuilder+ plannerBuilder PlannerBuilder}// PlannerBuilder is a function that creates a PlanFunc given a Registry.@@ -42,31 +47,20 @@ type PlannerBuilder func(ctx context.Context, r *Registry) (agent.Agent, error)// Config configures the controller.type Config struct {- EventLogBuilder eventlog.EventLogBuilder+ EventLogBuilder task.EventLogBuilderPlannerBuilder PlannerBuilder// TODO(jbd): Add CompacterBuilder.HealthCheck config.HealthCheckConfig- MaxSteps int}// New creates a new controller instance.func New(ctx context.Context, config Config) (*Controller, error) {- if config.MaxSteps == 0 {- config.MaxSteps = 5- }-if config.EventLogBuilder == nil {- config.EventLogBuilder = func(sessionID string) (eventlog.EventLog, error) {- return eventlog.NewFileEventLog(eventlog.FileConfig{- SessionID: sessionID,- Dir: "eventlog",- })+ config.EventLogBuilder = func(taskID string) (task.EventLog, error) {+ return task.OpenFileEventLog(path.Join(".", "tasklog", taskID+".jsonl"))}}- // Initialize session manager with file-based event logs- sessionManager := NewSessionManager(config.EventLogBuilder)-// Initialize agent registryregistry, err := NewRegistry(config.HealthCheck)if err != nil {@@ -77,38 +71,22 @@ func New(ctx context.Context, config Config) (*Controller, error) {// If no planner builder is provided, use the default Gemini planner.if config.PlannerBuilder == nil {config.PlannerBuilder = func(ctx context.Context, r *Registry) (agent.Agent, error) {- return NewGeminiPlanner(ctx, r, GeminiPlannerConfig{})+ return NewGeminiPlannerAgent(ctx, r, GeminiPlannerConfig{})}}- planner, err := config.PlannerBuilder(ctx, registry)- if err != nil {- return nil, fmt.Errorf("failed to create planner from builder: %w", err)- }-- // Initialize loop executor- loopExecutor, err := NewLoopExecutor(ctx, LoopConfig{- Registry: registry,- SessionManager: sessionManager,- MaxSteps: config.MaxSteps,- Planner: planner,- })- if err != nil {- return nil, fmt.Errorf("failed to create loop executor: %w", err)- }-return &Controller{inFlightSessions: make(map[string]struct{}),- sessionManager: sessionManager,registry: registry,- loopExecutor: loopExecutor,+ eventLogBuilder: config.EventLogBuilder,+ plannerBuilder: config.PlannerBuilder,}, nil}// TriggerSession triggers a new agentic loop session or resumes an existing one.// If sessionID is empty, a UUID will be generated.// If the session already exists, it will be resumed with optional new inputs.-func (d *Controller) TriggerSession(ctx context.Context, sessionID string, incoming *proto.ProcessRequest, handler agent.OutputHandler) error {+func (d *Controller) TriggerSession(ctx context.Context, sessionID string, agentID string, incoming *proto.ProcessRequest, handler agent.OutputHandler) error {if sessionID == "" {return fmt.Errorf("session_id is required")}@@ -117,49 +95,47 @@ func (d *Controller) TriggerSession(ctx context.Context, sessionID string, incomdefer cleanup()if inFlight {- return fmt.Errorf("session is already in flight")+ return fmt.Errorf("task %q is already in flight", sessionID)}- // Check if session already exists- sess, err := d.sessionManager.LoadSession(ctx, sessionID)+ planner, err := d.plannerBuilder(ctx, d.registry)if err != nil {- return fmt.Errorf("failed to load session from storage: %w", err)+ return fmt.Errorf("failed to create planner: %w", err)}-- if sess == nil {- // Session doesn't exist - create new session- // Checkpoint ID is ignored for new sessions- sess, err = d.sessionManager.NewSession(sessionID)- if err != nil {- return fmt.Errorf("failed to create session: %w", err)+ registry := d.registry.Map()+ registry[plannerAgentID] = planner+ registry["gemini"], err = NewGeminiAgent(ctx, GeminiConfig{})+ if err != nil {+ return err+ }+ o := func(resp *proto.ProcessResponse) error {+ // Always filter out from_cache results.+ if !resp.FromCache {+ return handler(resp)}+ return nil}- if sess.State() == proto.State_STATE_FAILED {- return fmt.Errorf("session has failed and cannot continue")+ // For testing only! Remove this once the project is stable.+ // TODO(jbd): Remove this before the release.+ if os.Getenv("GAR_TEST_AGENTS") == "1" {+ for id, agent := range testagent.Agents() {+ registry[id] = agent+ }+ if agentID == "" {+ agentID = "coding"+ }}- if err := d.loopExecutor.Execute(ctx, sess, incoming, handler); err != nil {- return fmt.Errorf("loop execution failed: %w", err)- }- return nil-}--func (d *Controller) markInFlight(sessionID string) (exists bool, cleanup func()) {- d.inFlightSessionsMu.Lock()- defer d.inFlightSessionsMu.Unlock()-- _, ok := d.inFlightSessions[sessionID]- if ok {- return true, func() {}- }- d.inFlightSessions[sessionID] = struct{}{}-- return false, func() {- d.inFlightSessionsMu.Lock()- delete(d.inFlightSessions, sessionID)- d.inFlightSessionsMu.Unlock()+ if agentID == "" {+ agentID = plannerAgentID}+ e := task.DefaultExecutor(d.eventLogBuilder, registry)+ return e.Exec(ctx, &agent.Task{+ ID: sessionID,+ AgentID: agentID,+ Inputs: incoming.Contents,+ }, o)}// ForkSession forks a session from a source session.@@ -171,35 +147,11 @@ func (d *Controller) ForkSession(ctx context.Context, sourceSessionID, sourceCheif destSessionID == "" {return fmt.Errorf("destination session ID is required")}-- srInFlight, srcCleanup := d.markInFlight(sourceSessionID)- defer srcCleanup()-- if srInFlight {- return fmt.Errorf("source session is already in flight")- }-- destFlight, destCleanup := d.markInFlight(destSessionID)- defer destCleanup()-- if destFlight {- return fmt.Errorf("destination session is already in flight")- }-- // Fork the session- _, err := d.sessionManager.ForkSession(ctx, sourceSessionID, sourceCheckpoint, destSessionID)- if err != nil {- return fmt.Errorf("failed to fork session: %w", err)- }+ panic("not yet implemented")return nil}-// LoadSession loads a session from event log.-func (d *Controller) LoadSession(ctx context.Context, sessionID string) (*Session, error) {- return d.sessionManager.LoadSession(ctx, sessionID)-}-// Registry returns the agent registry.func (d *Controller) Registry() *Registry {return d.registry@@ -210,6 +162,22 @@ func (d *Controller) Close() error {if err := d.registry.Close(); err != nil {return fmt.Errorf("failed to close registry: %w", err)}- d.sessionManager.CloseAll()return nil}++func (d *Controller) markInFlight(sessionID string) (exists bool, cleanup func()) {+ d.inFlightSessionsMu.Lock()+ defer d.inFlightSessionsMu.Unlock()++ _, ok := d.inFlightSessions[sessionID]+ if ok {+ return true, func() {}+ }+ d.inFlightSessions[sessionID] = struct{}{}++ return false, func() {+ d.inFlightSessionsMu.Lock()+ delete(d.inFlightSessions, sessionID)+ d.inFlightSessionsMu.Unlock()+ }+}diff --git a/internal/controller/gemini.go b/internal/controller/gemini.goindex f8007c4..4429238 100644--- a/internal/controller/gemini.go+++ b/internal/controller/gemini.go@@ -18,43 +18,37 @@ import ("context""errors""fmt"- "io"- "log""os"- "os/exec""runtime"- "strings""time""github.com/google/gar/agent"- "github.com/google/gar/internal/skills""github.com/google/gar/proto"- "github.com/google/uuid""google.golang.org/genai"- "google.golang.org/protobuf/types/known/structpb")-const bashToolName = "bash"--// GeminiPlannerConfig configures the Gemini-based planner.-type GeminiPlannerConfig struct {+// GeminiConfig configures the Gemini agent.+type GeminiConfig struct {APIKey string // Google AI API key (for programmatic use only; if empty, uses GEMINI_API_KEY env var - recommended)Model string // Model name (default: gemini-3-flash-preview)MaxTokens int32 // Max output tokens (default: 8192)Timeout time.Duration // Request timeout (default: 60s)SystemPrompt string // Custom system prompt (optional)- SkillsDir string // Directory for discovering skills (optional)}-func NewGeminiPlanner(ctx context.Context, registry *Registry, config GeminiPlannerConfig) (agent.Agent, error) {+// GeminiAgent implements task.Agent using Gemini.+type GeminiAgent struct {+ config GeminiConfig+ client *genai.Client+}++// NewGeminiAgent creates a new Gemini agent.+func NewGeminiAgent(ctx context.Context, config GeminiConfig) (*GeminiAgent, error) {if config.Timeout == 0 {config.Timeout = 30 * time.Second}if config.Model == "" {- config.Model = os.Getenv("GAR_GEMINI_MODEL")- if config.Model == "" {- config.Model = "gemini-3-flash-preview"- }+ config.Model = "gemini-3-flash-preview"}if config.APIKey == "" {config.APIKey = os.Getenv("GEMINI_API_KEY")@@ -62,151 +56,55 @@ func NewGeminiPlanner(ctx context.Context, registry *Registry, config GeminiPlanreturn nil, fmt.Errorf("GEMINI_API_KEY not set and no API key provided in config")}}-- // Default system prompt- if config.SystemPrompt == "" {- config.SystemPrompt = `You are an intelligent orchestrator. Your role is to analyze the conversation history and user requests, then select the most appropriate agent to handle the task.--Available tools have been provided to you as function tools. Each agent has:-- A unique ID-- A description of its capabilities--Your job is to:-1. Analyze the current conversation context and understand what needs to be done-2. Select the best tool for the task by calling the appropriate function-3. If enough work is done, stop to indicate completion--Guidelines:-- Choose tools based on their capabilities and the user's needs.-- Keep responses concise, don't chat too much about what you can do.-- If no suitable tool exists, stop.-- Keep the conversation context in mind when selecting tools.-- It's valid not to choose a tool.-- Once something is approved, try executing it.`- }-client, err := genai.NewClient(ctx, &genai.ClientConfig{APIKey: config.APIKey,})if err != nil {return nil, fmt.Errorf("failed to create Gemini client: %w", err)}-- skillsDir := config.SkillsDir- if skillsDir == "" {- skillsDir = os.Getenv("SKILLS_DIR")- }- if skillsDir == "" {- skillsDir = skills.DefaultDir()- }-- skillExec, err := skills.NewExecutor(client, config.Model, skillsDir)- if err != nil && err != io.EOF {- log.Printf("Warning: failed to initialize skill executor for %q: %v\n", skillsDir, err)- }-- if skillExec != nil && skillExec.HasSkills() {- config.SystemPrompt += "\n\n" + skillExec.SystemPrompt()-- skillExec.OnUpdate(func(ev skills.UpdateEvent) {- // No-op for cleaner CLI logs- })- }-- return &geminiPlannerAgent{- client: client,- bashTool: newBashTool(),- registry: registry,- config: config,- skillExec: skillExec,+ return &GeminiAgent{+ config: config,+ client: client,}, nil}-type geminiPlannerAgent struct {- client *genai.Client- bashTool *bashTool- registry *Registry- config GeminiPlannerConfig- skillExec *skills.Executor-}--// agentsToTools converts registry agents to Gemini function declarations.-func agentsToTools(bashTool *bashTool, registry *Registry) ([]*genai.Tool, error) {- healthyAgents := registry.ListHealthy()-- var tools []*genai.Tool- // TODO(lhuan): Check if agentsToTools returns an error or empty list and return a friendly "no agent available, try later" error.- for _, id := range healthyAgents {- info, err := registry.GetInfo(id)- if err != nil {- continue // Skip agents we can't get info for- }-- // Create a function declaration for this agent- funcDecl := &genai.FunctionDeclaration{- Name: id, // Use agent ID as function name- Description: fmt.Sprintf("%s, %s", info.Name, info.Description),- }-- tools = append(tools, &genai.Tool{- FunctionDeclarations: []*genai.FunctionDeclaration{funcDecl},- })- }- tools = append(tools, bashTool.funcDecl())- return tools, nil-}--func (p *geminiPlannerAgent) Process(ctx context.Context, sessionID string, incoming *proto.ProcessRequest, handler agent.OutputHandler) error {- // Convert agents to Gemini function declarations- tools, err := agentsToTools(p.bashTool, p.registry)- if err != nil {- return fmt.Errorf("failed to convert agents to tools: %w", err)- }- if p.skillExec != nil && p.skillExec.HasSkills() {- tools = append(tools, skills.BuildTool(p.skillExec.SkillNames()))- }-- // Convert session to conversation history- contents := protoToContents(incoming.Contents)- ctx, cancel := context.WithTimeout(ctx, p.config.Timeout)+func (a *GeminiAgent) Process(ctx context.Context, t *agent.Task, e agent.TaskExecutor, handler agent.OutputHandler) error {+ inputs := t.Inputs+ contents := protoToContents(inputs)+ ctx, cancel := context.WithTimeout(ctx, a.config.Timeout)defer cancel()- resp, err := p.client.Models.GenerateContent(ctx, p.config.Model, contents, &genai.GenerateContentConfig{- Tools: tools,- ToolConfig: &genai.ToolConfig{- FunctionCallingConfig: &genai.FunctionCallingConfig{- Mode: genai.FunctionCallingConfigModeAuto,- },- },- SystemInstruction: genai.Text(p.config.SystemPrompt)[0],- MaxOutputTokens: p.config.MaxTokens,+ var systemPrompt *genai.Content+ if a.config.SystemPrompt != "" {+ systemPrompt = genai.Text(a.config.SystemPrompt)[0]+ }+ resp, err := a.client.Models.GenerateContent(ctx, a.config.Model, contents, &genai.GenerateContentConfig{+ SystemInstruction: systemPrompt,+ MaxOutputTokens: a.config.MaxTokens,CandidateCount: 1,})-if err != nil {- return fmt.Errorf("failed to generate in planner: %w", err)+ return fmt.Errorf("failed to generate: %w", err)}+if len(resp.Candidates) == 0 {return fmt.Errorf("no candidates from Gemini in planner")}candidate := resp.Candidates[0]if candidate.Content == nil || candidate.Content.Parts == nil {- if candidate.FinishReason == genai.FinishReasonStop {- return nil // No more tasks- }return fmt.Errorf("no content in candidates from Gemini")}- // Look for function calls in the response+ respCount := 0for _, part := range candidate.Content.Parts {if part == nil {continue}-if part.Text != "" {+ respCount++if err := handler(&proto.ProcessResponse{Contents: []*proto.Content{{- Role: "assistant",+ Role: "model",Content: &proto.Content_Text{Text: &proto.TextContent{Text: part.Text},},@@ -215,230 +113,22 @@ func (p *geminiPlannerAgent) Process(ctx context.Context, sessionID string, incoreturn err}}-- if fc := part.FunctionCall; fc != nil {- argsStruct, err := structpb.NewStruct(fc.Args)- if err != nil {- return fmt.Errorf("failed to convert function call args to structpb: %w", err)- }- if err := handler(&proto.ProcessResponse{- Contents: []*proto.Content{{- Role: "assistant",- Content: &proto.Content_FunctionCall{- FunctionCall: &proto.FunctionCallContent{- Name: fc.Name,- Args: argsStruct,- Id: fc.ID,- ThoughtSignature: part.ThoughtSignature,- },- },- }},- }); err != nil {- return err- }-- switch fc.Name {- case "activate_skill", "run_skill_script":- if p.skillExec == nil {- return fmt.Errorf("skill executor not initialized")- }-- if fc.Name == "run_skill_script" {- skill, _ := fc.Args["skill"].(string)- script, _ := fc.Args["script"].(string)- question := fmt.Sprintf("Can I run script %q from skill %q?", script, skill)-- continueProcessing, err := checkCommandApproval(incoming.Contents, question, handler)- if err != nil {- return err- }- if !continueProcessing {- return nil- }- }-- resultPart := p.skillExec.HandleCall(ctx, fc)-- // Format the output for GAR's text-based history log- var output string- if resultPart != nil && resultPart.FunctionResponse != nil {- resultMap := resultPart.FunctionResponse.Response- if body, ok := resultMap["instructions"]; ok {- output = body.(string)- } else if errStr, ok := resultMap["error"]; ok {- output = "Error: " + errStr.(string)- } else {- if so, ok := resultMap["stdout"].(string); ok && so != "" {- output += so- }- if se, ok := resultMap["stderr"].(string); ok && se != "" {- if output != "" {- output += "\n"- }- output += "Stderr: " + se- }- if output == "" {- output = "Command executed successfully (no output)"- }- }- } else {- output = "Error: nil response from executor"- }-- // Explicitly format as a tool result so the reconstructed history doesn't confuse the model- respStruct, err := structpb.NewStruct(map[string]interface{}{"result": output})- if err != nil {- return fmt.Errorf("failed to convert function response to structpb: %w", err)- }-- return handler(&proto.ProcessResponse{- Contents: []*proto.Content{{- Role: "assistant",- Content: &proto.Content_FunctionResponse{- FunctionResponse: &proto.FunctionResponseContent{- Name: fc.Name,- Response: respStruct,- Id: fc.ID,- },- },- }},- AgentHandoff: plannerAgentID,- })-- case bashToolName:- command, ok := fc.Args["command"].(string)- if !ok {- return fmt.Errorf("command parameter missing or invalid in function call")- }- question := fmt.Sprintf("Can I execute %q?", command)-- continueProcessing, err := checkCommandApproval(incoming.Contents, question, handler)- if err != nil {- return err- }- if !continueProcessing {- return nil- }-- output, err := p.bashTool.executeShellCommand(fc.Args)- if err != nil {- return err- }-- respStruct, err := structpb.NewStruct(map[string]interface{}{"result": output})- if err != nil {- return fmt.Errorf("failed to convert function response to structpb: %w", err)- }-- return handler(&proto.ProcessResponse{- Contents: []*proto.Content{{- Role: "assistant", // Note: The history uses assistant for now- Content: &proto.Content_FunctionResponse{- FunctionResponse: &proto.FunctionResponseContent{- Name: fc.Name,- Response: respStruct,- Id: fc.ID,- },- },- }},- AgentHandoff: plannerAgentID, // Explicitly return to planner in same response- })- default:- return handler(&proto.ProcessResponse{- AgentHandoff: fc.Name,- })- }- }+ }+ if respCount == 0 {+ return errors.New("no responses from Gemini")}return nil}-// HealthCheck checks if the agent is healthy and responsive.-// Returns an error if the agent is unhealthy or unreachable.-func (p *geminiPlannerAgent) HealthCheck(ctx context.Context) error {- return nil // always healthy+func (a *GeminiAgent) HealthCheck(ctx context.Context) error {+ return nil}-// Close gracefully shuts down the agent and releases resources.-func (p *geminiPlannerAgent) Close() error {+func (a *GeminiAgent) Close() error {return nil}-// protoToContents converts session message history to Gemini conversation format.-func protoToContents(inputs []*proto.Content) []*genai.Content {- var contents []*genai.Content-- // Convert each message to Gemini format- for _, msg := range inputs {- role := msg.Role- if role != "user" {- role = "model"- }-- switch m := msg.Content.(type) {- case *proto.Content_Text:- contents = append(contents, &genai.Content{- Role: role,- Parts: []*genai.Part{- {- Text: m.Text.Text,- },- },- })- case *proto.Content_Confirmation:- if m.Confirmation.Question != "" {- contents = append(contents, &genai.Content{- Role: "model",- Parts: []*genai.Part{- {Text: m.Confirmation.Question},- },- })- }- switch d := m.Confirmation.Decision.(type) {- case *proto.ConfirmationContent_Decline:- // should never happen- case *proto.ConfirmationContent_Approval:- if d.Approval.Approved {- contents = append(contents, &genai.Content{- Role: "user",- Parts: []*genai.Part{- {Text: "Approved."},- },- })- }- }- case *proto.Content_FunctionCall:- contents = append(contents, &genai.Content{- Role: "model",- Parts: []*genai.Part{- {- ThoughtSignature: m.FunctionCall.ThoughtSignature,- FunctionCall: &genai.FunctionCall{- ID: m.FunctionCall.Id,- Name: m.FunctionCall.Name,- Args: m.FunctionCall.Args.AsMap(),- },- },- },- })- case *proto.Content_FunctionResponse:- contents = append(contents, &genai.Content{- Role: "user",- Parts: []*genai.Part{- {- FunctionResponse: &genai.FunctionResponse{- ID: m.FunctionResponse.Id,- Name: m.FunctionResponse.Name,- Response: m.FunctionResponse.Response.AsMap(),- },- },- },- })- }- // TODO(jbd): Handle other content types (e.g., images, files)- }- return contents-}+const bashToolName = "bash"func newBashTool() *bashTool {return &bashTool{}@@ -446,8 +136,7 @@ func newBashTool() *bashTool {// bashTool is the built-in tool that allows// planner to execute general purpose bash commands.-type bashTool struct {-}+type bashTool struct{}func (f *bashTool) funcDecl() *genai.Tool {osInfo := fmt.Sprintf("User's Operating System: %s (%s)", runtime.GOOS, runtime.GOARCH)@@ -472,77 +161,3 @@ func (f *bashTool) funcDecl() *genai.Tool {},}}--func (f *bashTool) executeShellCommand(args map[string]any) (string, error) {- command, ok := args["command"].(string)- if !ok {- return "", fmt.Errorf("command parameter missing or invalid")- }-- // Execute the command.- var cmd *exec.Cmd- if runtime.GOOS == "windows" {- cmd = exec.Command("cmd", "/C", command)- } else {- cmd = exec.Command("sh", "-c", command)- }-- output, err := cmd.CombinedOutput()- if err != nil {- // Return both the error and any output that was produced- return fmt.Sprintf("Error: %v\nOutput: %s\n\n", err, output), nil- }-- result := strings.TrimSpace(string(output))- if result == "" {- return "Command executed successfully (no output)", nil- }- result += "\n\n"-- return result, nil-}--// checkCommandApproval checks if the user has approved or declined the command.-// It searches backwards through the history for a confirmation request with the same question-// and then looks for the user's response to that confirmation.-// This isn't a true implementation based on id checking, but it's good enough for now.-func checkCommandApproval(history []*proto.Content, question string, handler agent.OutputHandler) (cont bool, err error) {- // Find the most recent confirmation request testing this question- var expectedID string- for i := len(history) - 1; i >= 0; i-- {- c := history[i]- if conf := c.GetConfirmation(); conf != nil && c.Role == "assistant" && conf.Question == question {- expectedID = conf.Id- break- }- }-- if expectedID != "" {- // Find the user's response to this confirmation ID- for i := len(history) - 1; i >= 0; i-- {- c := history[i]- if conf := c.GetConfirmation(); conf != nil && c.Role == "user" && conf.Id == expectedID {- if approval := conf.GetApproval(); approval != nil {- if approval.Approved {- return true, nil- }- }- return false, errors.New("commands must be already approved before geminiPlannerAgent.Process")- }- }- }-- // Not decided yet, prompt the user for confirmation.- err = handler(&proto.ProcessResponse{- Contents: []*proto.Content{{- Role: "assistant",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: uuid.New().String(),- Question: question,- },- },- }},- })- return false, err-}diff --git a/internal/controller/gemini_planner.go b/internal/controller/gemini_planner.gonew file mode 100644index 0000000..e1c5b12--- /dev/null+++ b/internal/controller/gemini_planner.go@@ -0,0 +1,590 @@+package controller++import (+ "context"+ "fmt"+ "os"+ "os/exec"+ "runtime"+ "strings"+ "time"++ "github.com/google/gar/agent"+ "github.com/google/gar/internal/skills"+ "github.com/google/gar/proto"+ "github.com/google/uuid"+ "google.golang.org/genai"+ "google.golang.org/protobuf/types/known/structpb"+)++// GeminiPlannerConfig configures the Gemini-based planner.+type GeminiPlannerConfig struct {+ GeminiConfig GeminiConfig+ SkillsDir string // Directory for discovering skills (optional)+ MaxSteps int // Max steps (default: 100)+}++// geminiPlannerAgent implements task.Agent using Gemini.+type geminiPlannerAgent struct {+ config GeminiPlannerConfig+ client *genai.Client+ bashTool *bashTool+ registry *Registry+ skillExec *skills.Executor+}++// NewGeminiPlannerAgent creates a new Gemini-based agent.+func NewGeminiPlannerAgent(ctx context.Context, registry *Registry, config GeminiPlannerConfig) (agent.Agent, error) {+ if config.GeminiConfig.Timeout == 0 {+ config.GeminiConfig.Timeout = 30 * time.Second+ }+ if config.GeminiConfig.Model == "" {+ config.GeminiConfig.Model = os.Getenv("GAR_GEMINI_MODEL")+ if config.GeminiConfig.Model == "" {+ config.GeminiConfig.Model = "gemini-3-flash-preview"+ }+ }+ if config.GeminiConfig.APIKey == "" {+ config.GeminiConfig.APIKey = os.Getenv("GEMINI_API_KEY")+ if config.GeminiConfig.APIKey == "" {+ return nil, fmt.Errorf("GEMINI_API_KEY not set and no API key provided in config")+ }+ }++ if config.MaxSteps == 0 {+ config.MaxSteps = 5+ }++ // Default system prompt+ if config.GeminiConfig.SystemPrompt == "" {+ config.GeminiConfig.SystemPrompt = `You are an intelligent orchestrator. Your role is to analyze the conversation history and user requests, then select the most appropriate agent to handle the task.++Available tools have been provided to you as function tools. Each agent has:+- A unique ID+- A description of its capabilities++Your job is to:+1. Analyze the current conversation context and understand what needs to be done+2. Select the best tool for the task by calling the appropriate function+3. If enough work is done, stop to indicate completion++Guidelines:+- Choose tools based on their capabilities and the user's needs.+- Keep responses concise, don't chat too much about what you can do.+- If no suitable tool exists, stop.+- Keep the conversation context in mind when selecting tools.+- It's valid not to choose a tool.+- Once something is approved, try executing it.`+ }++ client, err := genai.NewClient(ctx, &genai.ClientConfig{+ APIKey: config.GeminiConfig.APIKey,+ })+ if err != nil {+ return nil, fmt.Errorf("failed to create Gemini client: %w", err)+ }++ skillsDir := config.SkillsDir+ if skillsDir == "" {+ skillsDir = os.Getenv("SKILLS_DIR")+ }+ if skillsDir == "" {+ skillsDir = skills.DefaultDir()+ }++ skillExec, err := skills.NewExecutor(client, config.GeminiConfig.Model, skillsDir)+ if err != nil {+ return nil, err+ }++ if skillExec.HasSkills() {+ // config.SystemPrompt += "\n\n" + skillExec.SystemPrompt()+ }+ return &geminiPlannerAgent{+ client: client,+ bashTool: newBashTool(),+ registry: registry,+ config: config,+ skillExec: skillExec,+ }, nil+}++func (p *geminiPlannerAgent) Process(ctx context.Context, t *agent.Task, e agent.TaskExecutor, handler agent.OutputHandler) error {+ var outputs []*proto.Content+ var outputCapturer = func(resp *proto.ProcessResponse) error {+ outputs = append(outputs, resp.Contents...)+ return handler(resp)+ }++ t.Inputs = append(t.Inputs, outputs...)+ nextAgentID, err := p.process(ctx, t, outputCapturer)+ if err != nil {+ return err+ }+ if nextAgentID == "" {+ return nil+ }+ if err := e.Exec(ctx, &agent.Task{+ ID: nextAgentID,+ AgentID: nextAgentID,+ Inputs: t.Inputs,+ }, handler); err != nil {+ return err+ }+ return nil+}++func (p *geminiPlannerAgent) HealthCheck(ctx context.Context) error {+ return nil+}++func (p *geminiPlannerAgent) Close() error {+ return nil+}++func (p *geminiPlannerAgent) process(ctx context.Context, t *agent.Task, handler agent.OutputHandler) (agentID string, err error) {+ tools, err := agentsToTools(p.bashTool, p.registry)+ if err != nil {+ return "", fmt.Errorf("failed to convert agents to tools: %w", err)+ }+ if p.skillExec.HasSkills() {+ // tools = append(tools, skills.BuildTool(p.skillExec.SkillNames()))+ }++ inputs := t.Inputs+ if fc, approved := p.handleConfirmationAnswer(inputs); fc != nil {+ return "", p.handleExecute(ctx, fc, approved, handler)+ }++ contents := protoToContents(inputs)+ ctx, cancel := context.WithTimeout(ctx, p.config.GeminiConfig.Timeout)+ defer cancel()++ resp, err := p.client.Models.GenerateContent(ctx, p.config.GeminiConfig.Model, contents, &genai.GenerateContentConfig{+ Tools: tools,+ ToolConfig: &genai.ToolConfig{+ FunctionCallingConfig: &genai.FunctionCallingConfig{+ Mode: genai.FunctionCallingConfigModeAuto,+ },+ },+ SystemInstruction: genai.Text(p.config.GeminiConfig.SystemPrompt)[0],+ MaxOutputTokens: p.config.GeminiConfig.MaxTokens,+ CandidateCount: 1,+ })++ if err != nil {+ return "", fmt.Errorf("failed to generate in planner: %w", err)+ }+ if len(resp.Candidates) == 0 {+ return "", fmt.Errorf("no candidates from Gemini in planner")+ }+ candidate := resp.Candidates[0]+ if candidate.Content == nil || candidate.Content.Parts == nil {+ if candidate.FinishReason == genai.FinishReasonStop {+ return "", nil // No more tasks+ }+ return "", fmt.Errorf("no content in candidates from Gemini")+ }++ // Look for function calls in the response+ for _, part := range candidate.Content.Parts {+ if part == nil {+ continue+ }++ if part.Text != "" {+ if err := handler(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{Text: part.Text},+ },+ }},+ }); err != nil {+ return "", err+ }+ }++ if fc := part.FunctionCall; fc != nil {+ fc.ID = uuid.NewString()+ switch fc.Name {+ case bashToolName:+ return "", p.handleBash(fc, handler)+ case "run_skill_script", "activate_skill":+ return "", p.handleSkill(ctx, fc, handler)+ default:+ return fc.Name, nil+ }+ }+ }+ return "", nil+}++func (p *geminiPlannerAgent) handleSkill(ctx context.Context, fc *genai.FunctionCall, o agent.OutputHandler) error {+ if fc.Name == "run_skill_script" {+ skill, _ := fc.Args["skill"].(string)+ script, _ := fc.Args["script"].(string)+ question := fmt.Sprintf("Can I run script %q from skill %q?", script, skill)++ argsStruct, err := structpb.NewStruct(fc.Args)+ if err != nil {+ return err+ }+ return o(&proto.ProcessResponse{+ Contents: []*proto.Content{+ {+ Content: &proto.Content_FunctionCall{+ FunctionCall: &proto.FunctionCallContent{+ Id: fc.ID,+ Name: fc.Name,+ Args: argsStruct,+ },+ },+ },+ {+ Content: &proto.Content_Confirmation{+ Confirmation: &proto.ConfirmationContent{+ Id: fc.ID,+ Question: question,+ },+ },+ }},+ })+ }++ resultPart := p.skillExec.HandleCall(ctx, fc)+ var output string+ if resultPart != nil && resultPart.FunctionResponse != nil {+ resultMap := resultPart.FunctionResponse.Response+ if body, ok := resultMap["instructions"]; ok {+ output = body.(string)+ } else if errStr, ok := resultMap["error"]; ok {+ output = "Error: " + errStr.(string)+ } else {+ if so, ok := resultMap["stdout"].(string); ok && so != "" {+ output += so+ }+ if se, ok := resultMap["stderr"].(string); ok && se != "" {+ if output != "" {+ output += "\n"+ }+ output += "Stderr: " + se+ }+ if output == "" {+ output = "Command executed successfully (no output)"+ }+ }+ } else {+ output = "Error: nil response from executor"+ }++ respStruct, err := structpb.NewStruct(map[string]any{"result": output})+ if err != nil {+ return fmt.Errorf("failed to convert function response to structpb: %w", err)+ }+ return o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_FunctionResponse{+ FunctionResponse: &proto.FunctionResponseContent{+ Name: fc.Name,+ Response: respStruct,+ Id: fc.ID,+ },+ },+ }},+ })+}++func (p *geminiPlannerAgent) handleBash(fc *genai.FunctionCall, o agent.OutputHandler) error {+ command, _ := fc.Args["command"].(string)+ argsStruct, err := structpb.NewStruct(fc.Args)+ if err != nil {+ return err+ }+ return o(&proto.ProcessResponse{+ Contents: []*proto.Content{+ {+ Content: &proto.Content_FunctionCall{+ FunctionCall: &proto.FunctionCallContent{+ Id: fc.ID,+ Name: fc.Name,+ Args: argsStruct,+ },+ },+ },+ {+ Content: &proto.Content_Confirmation{+ Confirmation: &proto.ConfirmationContent{+ Id: fc.ID,+ Question: fmt.Sprintf("Can I run %q?", command),+ },+ },+ }},+ })++}++func (p *geminiPlannerAgent) handleExecute(ctx context.Context, fc *genai.FunctionCall, approved bool, o agent.OutputHandler) error {+ if !approved {+ // Declined, nothing to do in terms of executing any commands.+ // But we still have to finish with a function response,+ // not to keep the previously log function call hanging forever.+ return o(&proto.ProcessResponse{+ Contents: []*proto.Content{+ {+ Role: "assistant",+ Content: &proto.Content_FunctionResponse{+ FunctionResponse: &proto.FunctionResponseContent{+ Name: fc.Name,+ Id: fc.ID,+ },+ },+ },+ {+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "Okay.",+ },+ },+ },+ },+ })+ }++ var output string+ switch fc.Name {+ case "bash":+ var err error+ output, err = execute(fc.Args)+ if err != nil {+ return err+ }+ case "run_skill_script":+ result := p.skillExec.HandleCall(ctx, fc)+ if result != nil && result.FunctionResponse != nil {+ resultMap := result.FunctionResponse.Response+ if body, ok := resultMap["instructions"]; ok {+ output = body.(string)+ } else if errStr, ok := resultMap["error"]; ok {+ output = "Error: " + errStr.(string)+ } else {+ if so, ok := resultMap["stdout"].(string); ok && so != "" {+ output += so+ }+ if se, ok := resultMap["stderr"].(string); ok && se != "" {+ if output != "" {+ output += "\n"+ }+ output += "Stderr: " + se+ }+ }+ } else {+ output = "Error: nil response from executor"+ }+ }+ respStruct, err := structpb.NewStruct(map[string]any{"result": output})+ if err != nil {+ return fmt.Errorf("failed to convert function response to structpb: %w", err)+ }+ return o(&proto.ProcessResponse{+ Contents: []*proto.Content{+ {+ Role: "assistant",+ Content: &proto.Content_FunctionResponse{+ FunctionResponse: &proto.FunctionResponseContent{+ Name: fc.Name,+ Response: respStruct,+ Id: fc.ID,+ },+ },+ },+ {+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: output,+ },+ },+ },+ },+ })+}++func (p *geminiPlannerAgent) handleConfirmationAnswer(inputs []*proto.Content) (*genai.FunctionCall, bool) {+ var conf *proto.ConfirmationContent+ var approved bool+ for _, input := range inputs {+ if input.GetConfirmation() != nil && input.GetConfirmation().GetApproval() != nil {+ conf = input.GetConfirmation()+ approved = true+ }+ if input.GetConfirmation() != nil && input.GetConfirmation().GetDecline() != nil {+ conf = input.GetConfirmation()+ approved = false+ }+ }+ if conf == nil {+ return nil, false+ }++ var fc *genai.FunctionCall+ for _, input := range inputs {+ if input.GetFunctionCall() == nil {+ continue+ }+ if fn := input.GetFunctionCall(); fn != nil && fn.Id == conf.Id {+ fc = &genai.FunctionCall{+ ID: conf.Id,+ Name: fn.Name,+ Args: fn.Args.AsMap(),+ }+ break+ }+ }++ if fc == nil {+ return nil, false+ }++ // Ensure that we don't have a response for the function call.+ // Otherwise, we will execute the function call forever.+ for _, input := range inputs {+ if input.GetFunctionResponse() == nil {+ continue+ }+ if fr := input.GetFunctionResponse(); fr != nil && fr.Id == fc.ID {+ // We executed this previously.+ // There is nothing more to execute.+ return nil, false+ }+ }+ return fc, approved+}++// agentsToTools converts registry agents to Gemini function declarations.+func agentsToTools(bashTool *bashTool, registry *Registry) ([]*genai.Tool, error) {+ healthyAgents := registry.ListHealthy()++ var tools []*genai.Tool+ // TODO(lhuan): Check if agentsToTools returns an error or empty list and return a friendly "no agent available, try later" error.+ for _, id := range healthyAgents {+ info, err := registry.GetInfo(id)+ if err != nil {+ continue // Skip agents we can't get info for+ }++ // Create a function declaration for this agent+ funcDecl := &genai.FunctionDeclaration{+ Name: id, // Use agent ID as function name+ Description: fmt.Sprintf("%s, %s", info.Name, info.Description),+ }++ tools = append(tools, &genai.Tool{+ FunctionDeclarations: []*genai.FunctionDeclaration{funcDecl},+ })+ }+ if bashTool != nil {+ tools = append(tools, bashTool.funcDecl())+ }+ return tools, nil+}++// protoToContents converts session message history to Gemini conversation format.+func protoToContents(inputs []*proto.Content) []*genai.Content {+ var contents []*genai.Content++ // Convert each message to Gemini format+ for _, msg := range inputs {+ role := msg.Role+ if role != "user" {+ role = "model"+ }++ switch m := msg.Content.(type) {+ case *proto.Content_Text:+ contents = append(contents, &genai.Content{+ Role: role,+ Parts: []*genai.Part{+ {+ Text: m.Text.Text,+ },+ },+ })+ case *proto.Content_Confirmation:+ if m.Confirmation.Question != "" {+ contents = append(contents, &genai.Content{+ Role: "model",+ Parts: []*genai.Part{+ {Text: m.Confirmation.Question},+ },+ })+ }+ switch m.Confirmation.Decision.(type) {+ case *proto.ConfirmationContent_Decline:+ // shouldn't be sent to Gemini+ case *proto.ConfirmationContent_Approval:+ // shouldn't be sent to Gemini+ }+ case *proto.Content_FunctionCall:+ contents = append(contents, &genai.Content{+ Role: "model",+ Parts: []*genai.Part{+ {+ ThoughtSignature: m.FunctionCall.ThoughtSignature,+ FunctionCall: &genai.FunctionCall{+ ID: m.FunctionCall.Id,+ Name: m.FunctionCall.Name,+ Args: m.FunctionCall.Args.AsMap(),+ },+ },+ },+ })+ case *proto.Content_FunctionResponse:+ contents = append(contents, &genai.Content{+ Role: "user",+ Parts: []*genai.Part{+ {+ FunctionResponse: &genai.FunctionResponse{+ ID: m.FunctionResponse.Id,+ Name: m.FunctionResponse.Name,+ Response: m.FunctionResponse.Response.AsMap(),+ },+ },+ },+ })+ }+ // TODO(jbd): Handle other content types (e.g., images, files)+ }+ return contents+}++func execute(args map[string]any) (string, error) {+ command, ok := args["command"].(string)+ if !ok {+ return "", fmt.Errorf("command parameter missing or invalid")+ }++ // Execute the command.+ var cmd *exec.Cmd+ if runtime.GOOS == "windows" {+ cmd = exec.Command("cmd", "/C", command)+ } else {+ cmd = exec.Command("sh", "-c", command)+ }++ output, err := cmd.CombinedOutput()+ if err != nil {+ // Return both the error and any output that was produced+ return fmt.Sprintf("Error: %v\nOutput: %s\n\n", err, output), nil+ }++ result := strings.TrimSpace(string(output))+ if result == "" {+ return "Command executed successfully (no output)", nil+ }+ result += "\n\n"++ return result, nil+}diff --git a/internal/controller/gemini_test.go b/internal/controller/gemini_test.godeleted file mode 100644index 309f2bb..0000000--- a/internal/controller/gemini_test.go+++ /dev/null@@ -1,240 +0,0 @@-// Copyright 2026 Google LLC-//-// Licensed under the Apache License, Version 2.0 (the "License");-// you may not use this file except in compliance with the License.-// You may obtain a copy of the License at-//-// http://www.apache.org/licenses/LICENSE-2.0-//-// Unless required by applicable law or agreed to in writing, software-// distributed under the License is distributed on an "AS IS" BASIS,-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-// See the License for the specific language governing permissions and-// limitations under the License.--package controller--import (- "testing"-- "github.com/google/gar/proto"-)--func TestCheckCommandApproval(t *testing.T) {- question := `Can I execute "ls -la"?`-- tests := []struct {- name string- history []*proto.Content- wantCont bool- wantErr bool- wantPrompted bool // whether handler should be called with a confirmation prompt- }{- {- name: "empty history prompts user",- history: nil,- wantCont: false,- wantErr: false,- wantPrompted: true,- },- {- name: "no matching confirmation prompts user",- history: []*proto.Content{- {Role: "user", Content: &proto.Content_Text{Text: &proto.TextContent{Text: "hello"}}},- {Role: "assistant", Content: &proto.Content_Text{Text: &proto.TextContent{Text: "hi"}}},- },- wantCont: false,- wantErr: false,- wantPrompted: true,- },- {- name: "broken history",- history: []*proto.Content{- {Role: "user", Content: &proto.Content_Text{Text: &proto.TextContent{Text: "hello"}}},- {Role: "assistant", Content: &proto.Content_Text{Text: &proto.TextContent{Text: "hi"}}},- {- Role: "user",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: "conf-1",- Decision: &proto.ConfirmationContent_Approval{- Approval: &proto.ApprovalDecision{Approved: true},- },- },- },- },- },- wantCont: false,- wantErr: false,- wantPrompted: true,- },- {- name: "matching confirmation with approval continues",- history: []*proto.Content{- {- Role: "assistant",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: "conf-1",- Question: question,- },- },- },- {- Role: "user",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: "conf-1",- Decision: &proto.ConfirmationContent_Approval{- Approval: &proto.ApprovalDecision{Approved: true},- },- },- },- },- },- wantCont: true,- wantErr: false,- wantPrompted: false,- },- {- name: "matching confirmation with decline returns error",- history: []*proto.Content{- {- Role: "assistant",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: "conf-2",- Question: question,- },- },- },- {- Role: "user",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: "conf-2",- Decision: &proto.ConfirmationContent_Decline{- Decline: &proto.DeclineDecision{Declined: true},- },- },- },- },- },- wantCont: false,- wantErr: true,- wantPrompted: false,- },- {- name: "confirmation for different question prompts user",- history: []*proto.Content{- {- Role: "assistant",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: "conf-3",- Question: `Can I execute "rm -rf /"?`,- },- },- },- {- Role: "user",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: "conf-3",- Decision: &proto.ConfirmationContent_Approval{- Approval: &proto.ApprovalDecision{Approved: true},- },- },- },- },- },- wantCont: false,- wantErr: false,- wantPrompted: true,- },- {- name: "confirmation asked but no response yet prompts user",- history: []*proto.Content{- {- Role: "assistant",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: "conf-4",- Question: question,- },- },- },- },- wantCont: false,- wantErr: false,- wantPrompted: true,- },- {- name: "response with mismatched ID prompts user again",- history: []*proto.Content{- {- Role: "assistant",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: "conf-5",- Question: question,- },- },- },- {- Role: "user",- Content: &proto.Content_Confirmation{- Confirmation: &proto.ConfirmationContent{- Id: "wrong-id",- Decision: &proto.ConfirmationContent_Approval{- Approval: &proto.ApprovalDecision{Approved: true},- },- },- },- },- },- wantCont: false,- wantErr: false,- wantPrompted: true,- },- }-- for _, tc := range tests {- t.Run(tc.name, func(t *testing.T) {- var prompted bool- handler := func(resp *proto.ProcessResponse) error {- prompted = true- // Verify the prompt contains a confirmation with the question- if len(resp.Contents) != 1 {- t.Fatalf("expected 1 content in prompt, got %d", len(resp.Contents))- }- conf := resp.Contents[0].GetConfirmation()- if conf == nil {- t.Fatal("expected confirmation content in prompt")- }- if conf.Question != question {- t.Errorf("expected question %q, got %q", question, conf.Question)- }- if conf.Id == "" {- t.Error("expected non-empty confirmation ID")- }- return nil- }-- cont, err := checkCommandApproval(tc.history, question, handler)-- if tc.wantErr && err == nil {- t.Error("expected error, got nil")- }- if !tc.wantErr && err != nil {- t.Errorf("unexpected error: %v", err)- }- if cont != tc.wantCont {- t.Errorf("expected cont=%v, got %v", tc.wantCont, cont)- }- if prompted != tc.wantPrompted {- t.Errorf("expected prompted=%v, got %v", tc.wantPrompted, prompted)- }- })- }-}diff --git a/internal/controller/loop.go b/internal/controller/loop.godeleted file mode 100644index 535167a..0000000--- a/internal/controller/loop.go+++ /dev/null@@ -1,248 +0,0 @@-// Copyright 2026 Google LLC-//-// Licensed under the Apache License, Version 2.0 (the "License");-// you may not use this file except in compliance with the License.-// You may obtain a copy of the License at-//-// http://www.apache.org/licenses/LICENSE-2.0-//-// Unless required by applicable law or agreed to in writing, software-// distributed under the License is distributed on an "AS IS" BASIS,-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-// See the License for the specific language governing permissions and-// limitations under the License.--package controller--import (- "context"- "fmt"-- "github.com/google/gar/agent"- "github.com/google/gar/proto"-)--const plannerAgentID = "__planner"--// LoopExecutor orchestrates the agentic loop workflow.-// It implements the plan-execute-evaluate-checkpoint cycle.-type LoopExecutor struct {- registry *Registry- sessionManager *SessionManager- maxSteps int- planner agent.Agent-}--// LoopConfig configures the loop executor.-type LoopConfig struct {- Registry *Registry- SessionManager *SessionManager- MaxSteps int- Planner agent.Agent-}--// NewLoopExecutor creates a new loop executor.-func NewLoopExecutor(ctx context.Context, config LoopConfig) (*LoopExecutor, error) {- if config.Registry == nil {- return nil, fmt.Errorf("registry cannot be nil")- }- if config.SessionManager == nil {- return nil, fmt.Errorf("session manager cannot be nil")- }- if config.MaxSteps == 0 {- return nil, fmt.Errorf("max_steps cannot be zero")- }- // Plan function is required- if config.Planner == nil {- return nil, fmt.Errorf("planner is required")- }-- return &LoopExecutor{- registry: config.Registry,- sessionManager: config.SessionManager,- maxSteps: config.MaxSteps,- planner: config.Planner,- }, nil-}--// Execute starts a new agentic loop execution for the given session.-func (e *LoopExecutor) Execute(ctx context.Context, session *Session, incoming *proto.ProcessRequest, handler agent.OutputHandler) error {- return e.runLoop(ctx, session, incoming, handler)-}--// runLoop executes the main agentic loop.-// It runs up to maxSteps iterations per trigger/resume invocation.-func (e *LoopExecutor) runLoop(ctx context.Context, session *Session, incoming *proto.ProcessRequest, handler agent.OutputHandler) error {- steps := 0-- for _, agentID := range session.WaitingAgents() {- buffer := session.WaitingBuffer(agentID)- _ = buffer-- return fmt.Errorf("resuming waiting agents is not yet supported")- }-- // Ensure the last confirmation question was answered.- exit, nextAgentID, err := e.handleConfirmation(ctx, session, incoming, handler)- if err != nil {- return err- }- if exit {- return nil- }- if nextAgentID == "" {- nextAgentID = plannerAgentID- }-- // Write the new inputs to the event log.- if err := session.WriteContent(ctx, "", incoming.CheckpointId, incoming.Contents); err != nil {- return fmt.Errorf("failed to write input content: %w", err)- }-- for steps < e.maxSteps {- // Check context cancellation- select {- case <-ctx.Done():- return ctx.Err()- default:- }-- history := session.History()- handoff, err := e.runAgent(ctx, session, nextAgentID, history, handler)- if err != nil {- return err- }-- if handoff == "" {- // No more agent handoffs to execute; loop is complete.- return nil- }-- nextAgentID = handoff- steps++- }-- // Can be resumed later with another trigger- return fmt.Errorf("max steps per trigger (%d) reached", e.maxSteps)-}--func (e *LoopExecutor) runAgent(ctx context.Context, session *Session, agentID string, inputs []*proto.Content, handler agent.OutputHandler) (handoff string, err error) {- var buffer []*proto.Content-- // Helper to flush buffer to session- flushBuffer := func(checkpointID string) error {- if len(buffer) == 0 {- return nil- }- if err := session.WriteContent(ctx, agentID, checkpointID, buffer); err != nil {- return fmt.Errorf("failed to write content: %w", err)- }- buffer = []*proto.Content{} // Clear buffer after successful write- return nil- }-- runHandler := func(outgoing *proto.ProcessResponse) error {- buffer = append(buffer, outgoing.Contents...)-- if outgoing.CheckpointId != "" {- if err := flushBuffer(outgoing.CheckpointId); err != nil {- return err- }- }-- if outgoing.AgentHandoff != "" {- // Write any pending content before handoff- if err := flushBuffer(""); err != nil {- return err- }-- handoff = outgoing.AgentHandoff- if err := session.WriteAgentHandoff(ctx, agentID, handoff); err != nil {- return fmt.Errorf("failed to write handoff: %w", err)- }- }- return handler(outgoing)- }-- var a agent.Agent- if agentID == plannerAgentID {- a = e.planner- } else {- a, err = e.registry.Get(agentID)- if err != nil {- return "", fmt.Errorf("failed to get agent: %w", err)- }- }-- if err := a.Process(ctx, session.ID(), &proto.ProcessRequest{- Contents: inputs,- }, runHandler); err != nil {- return "", fmt.Errorf("agent process failed: %w", err)- }-- // Final flush of any remaining buffer content- if err := flushBuffer(""); err != nil {- return "", err- }- return handoff, nil-}--// handleConfirmation checks if the session is waiting for a confirmation response,-// and if so, verifies that the incoming request provides a matching response.-// It returns a boolean indicating whether the loop should stop early, the agent to resume from, and an error.-func (e *LoopExecutor) handleConfirmation(ctx context.Context, session *Session, incoming *proto.ProcessRequest, handler agent.OutputHandler) (exitLoop bool, resumedAgentID string, err error) {- history := session.History()- if len(history) == 0 {- return false, "", nil- }- lastMsg := history[len(history)-1]- confReq := lastMsg.GetConfirmation()- if confReq == nil {- // not a confirmation question or answer- return false, "", nil- }-- if lastMsg.Role != "assistant" || confReq.Id == "" || confReq.Question == "" {- // not a confirmation question- return false, "", nil- }-- // Require the first incoming content to be the confirmation response- if len(incoming.Contents) == 0 {- return true, "", handler(&proto.ProcessResponse{- Contents: []*proto.Content{lastMsg},- })- }-- confResp := incoming.Contents[0].GetConfirmation()- if confResp == nil || (confResp.GetApproval() == nil && confResp.GetDecline() == nil) {- return true, "", handler(&proto.ProcessResponse{- Contents: []*proto.Content{lastMsg},- })- }-- if confResp.Id != confReq.Id {- return true, "", handler(&proto.ProcessResponse{- Contents: []*proto.Content{lastMsg},- })- }- if confResp.GetDecline() != nil {- out := []*proto.Content{{- Role: "assistant",- Content: &proto.Content_Text{- // Respond with "Ok" instead of the rejection decision- // to ensure the loop isn't stuck on that rejection decision.- // Models keep rejecting the confirmation in the lifetime- // of a session otherwise. Given we are explicitly asking- // for confirmation, this is safe.- Text: &proto.TextContent{Text: "Ok."},- },- }}-- if err := session.WriteContent(ctx, plannerAgentID, "", out); err != nil {- return true, "", fmt.Errorf("failed to write content: %w", err)- }- return true, "", handler(&proto.ProcessResponse{Contents: out})- }- return false, session.ConfirmationWaitingAgent(confResp.Id), nil-}diff --git a/internal/controller/registry.go b/internal/controller/registry.goindex 704b829..a873ce4 100644--- a/internal/controller/registry.go+++ b/internal/controller/registry.go@@ -71,6 +71,13 @@ func NewRegistry(healthCheckConfig config.HealthCheckConfig) (*Registry, error)return r, nil}+func (r *Registry) Map() map[string]agent.Agent {+ r.mu.RLock()+ defer r.mu.RUnlock()++ return r.agents+}+// RegisterLocal registers a local (in-process) agent.func (r *Registry) RegisterLocal(cfg config.LocalAgentConfig) error {r.mu.Lock()diff --git a/internal/controller/registry_test.go b/internal/controller/registry_test.goindex d9287c8..112f0cb 100644--- a/internal/controller/registry_test.go+++ b/internal/controller/registry_test.go@@ -31,14 +31,14 @@ import (// MockAgent is a mock implementation of the Agent interface for testing.type MockAgent struct {- processFunc func(ctx context.Context, sessionID string, req *proto.ProcessRequest, handler agent.OutputHandler) error+ processFunc func(ctx context.Context, t *agent.Task, e agent.TaskExecutor, o agent.OutputHandler) errorhealthCheckFunc func(ctx context.Context) errorcloseFunc func() error}-func (m *MockAgent) Process(ctx context.Context, sessionID string, req *proto.ProcessRequest, handler agent.OutputHandler) error {+func (m *MockAgent) Process(ctx context.Context, t *agent.Task, e agent.TaskExecutor, o agent.OutputHandler) error {if m.processFunc != nil {- return m.processFunc(ctx, sessionID, req, handler)+ return m.processFunc(ctx, t, e, o)}return nil}@@ -84,14 +84,12 @@ func startMockGRPCServer(t *testing.T, healthy bool) (string, func()) {}}--func TestRegistry_HealthCheckScenarios(t *testing.T) {tests := []struct {name stringenabled boolagentType string- expectHealthy bool+ expectHealthy bool}{{name: "Local Agent (Always Healthy)",@@ -165,7 +163,7 @@ func TestRegistry_HealthCheckScenarios(t *testing.T) {timeout := time.After(2 * time.Second)ticker := time.NewTicker(20 * time.Millisecond)defer ticker.Stop()-+success := falsefor !success {select {@@ -186,10 +184,10 @@ func TestRegistry_HealthCheckScenarios(t *testing.T) {// Should be immediately healthy (local or disabled)// Important: for disabled+remote, it is optimistically healthy.// For local, it is always healthy (unless manually updated, but default is true).-+// Wait a tiny bit just in case async things happen, but usually sync for registration- time.Sleep(10 * time.Millisecond)-+ time.Sleep(10 * time.Millisecond)+info, err := r.GetInfo(id)if err != nil {t.Fatalf("GetInfo failed: %v", err)@@ -202,8 +200,6 @@ func TestRegistry_HealthCheckScenarios(t *testing.T) {}}--func TestRegistry_GracefulShutdown(t *testing.T) {healthCheckConfig := config.HealthCheckConfig{Enabled: true,diff --git a/internal/controller/session.go b/internal/controller/session.godeleted file mode 100644index 0cb4112..0000000--- a/internal/controller/session.go+++ /dev/null@@ -1,454 +0,0 @@-// Copyright 2026 Google LLC-//-// Licensed under the Apache License, Version 2.0 (the "License");-// you may not use this file except in compliance with the License.-// You may obtain a copy of the License at-//-// http://www.apache.org/licenses/LICENSE-2.0-//-// Unless required by applicable law or agreed to in writing, software-// distributed under the License is distributed on an "AS IS" BASIS,-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-// See the License for the specific language governing permissions and-// limitations under the License.--package controller--import (- "context"- "fmt"- "sync"-- "github.com/google/gar/internal/eventlog"- "github.com/google/gar/proto"- pbproto "google.golang.org/protobuf/proto"- "google.golang.org/protobuf/types/known/timestamppb"-)--// Session represents an agentic loop execution session.-// It maintains in-memory state and uses event log for durability.-type Session struct {- id string-- mu sync.RWMutex- eventLog eventlog.EventLog- state proto.State- steps []*Step- waitingAgents map[string][]*proto.Content // by agent ID- checkpointIDs map[string]struct{} // checkpoint UUIDs-}--type Step struct {- AgentID string- Contents []*proto.Content-}--// SessionManager manages multiple sessions.-type SessionManager struct {- mu sync.RWMutex- sessions map[string]*Session- eventLogBuilder eventlog.EventLogBuilder-}--// NewSessionManager creates a new session manager with a custom EventLog builder.-func NewSessionManager(builder eventlog.EventLogBuilder) *SessionManager {- return &SessionManager{- sessions: make(map[string]*Session),- eventLogBuilder: builder,- }-}--// NewSession creates a new session with the given ID.-func (sm *SessionManager) NewSession(sessionID string) (*Session, error) {- if err := validateID(sessionID); err != nil {- return nil, err- }- sm.mu.Lock()- defer sm.mu.Unlock()-- // Check if session already exists- if _, ok := sm.sessions[sessionID]; ok {- return nil, fmt.Errorf("session %s already exists", sessionID)- }-- // Create event log for this session using the builder.- el, err := sm.eventLogBuilder(sessionID)- if err != nil {- return nil, fmt.Errorf("failed to create event log: %w", err)- }-- session := &Session{- id: sessionID,- state: proto.State_STATE_UNSPECIFIED,- steps: []*Step{},- waitingAgents: make(map[string][]*proto.Content),- checkpointIDs: make(map[string]struct{}),- eventLog: el,- }-- sm.sessions[sessionID] = session- return session, nil-}--// LoadSession loads an existing session from event log.-func (sm *SessionManager) LoadSession(ctx context.Context, sessionID string) (*Session, error) {- return sm.LoadSessionFromCheckpoint(ctx, sessionID, "")-}--// LoadSessionFromCheckpoint loads an existing session from event log up to a specific checkpoint.-// If checkpointID is empty, loads to the latest state.-// If checkpointID is provided, loads up to and including that checkpoint UUID.-func (sm *SessionManager) LoadSessionFromCheckpoint(ctx context.Context, sessionID, checkpointID string) (*Session, error) {- if err := validateID(sessionID); err != nil {- return nil, err- }-- // 1. Load events from storage (IO) - No Lock- // We do this without holding the lock to allow concurrent reads/writes on other sessions.- el, events, state, err := sm.loadEvents(ctx, sessionID, checkpointID)- if err != nil {- return nil, err- }-- // 2. Construct session state in memory - No Lock- session := &Session{- id: sessionID,- state: state,- eventLog: el,- waitingAgents: make(map[string][]*proto.Content),- steps: []*Step{},- checkpointIDs: make(map[string]struct{}),- }-- err = session.reconstructState(events)- if err != nil {- _ = el.Close()- return nil, err- }-- // 3. Commit to manager (Write Lock)- sm.mu.Lock()- defer sm.mu.Unlock()-- // Overwrite existing session (atomic switch)- // If a session existed, it is replaced by the reloaded version.- // The old session instance (if any) is discarded from the map.- // Note: We don't explicitly close the session's event log here because it might be in use elsewhere.- sm.sessions[sessionID] = session- return session, nil-}--// loadEvents opens the event log and loads events up to the checkpoint.-func (sm *SessionManager) loadEvents(ctx context.Context, sessionID, checkpointID string) (eventlog.EventLog, []*proto.Event, proto.State, error) {- // Open event log for replay using the factory- el, err := sm.eventLogBuilder(sessionID)- if err != nil {- return nil, nil, proto.State_STATE_UNSPECIFIED, fmt.Errorf("failed to open event log for replay: %w", err)- }-- events, state, err := el.LoadEvents(ctx, checkpointID)- if err != nil {- // Clean up potentially opened event log- _ = el.Close()- return nil, nil, proto.State_STATE_UNSPECIFIED, fmt.Errorf("failed to get event log entries: %w", err)- }-- return el, events, state, nil-}--// ForkSession creates a new session by forking from a source session's checkpoint.-func (sm *SessionManager) ForkSession(ctx context.Context, sourceSessionID, sourceCheckpointID, newSessionID string) (*Session, error) {- if err := validateID(sourceSessionID); err != nil {- return nil, fmt.Errorf("invalid source session ID: %w", err)- }- if err := validateID(newSessionID); err != nil {- return nil, fmt.Errorf("invalid new session ID: %w", err)- }-- // 1. Check if session already exists in backend storage- newEL, existingEvents, _, err := sm.loadEvents(ctx, newSessionID, "")- if err != nil {- return nil, fmt.Errorf("failed to initialize new session: %w", err)- }- if len(existingEvents) > 0 {- _ = newEL.Close()- return nil, fmt.Errorf("session %s already exists in storage", newSessionID)- }-- // 2. Load Source Events- sourceEL, sourceEvents, _, err := sm.loadEvents(ctx, sourceSessionID, sourceCheckpointID)- if err != nil {- _ = newEL.Close()- return nil, fmt.Errorf("failed to load source events: %w", err)- }- // Close source EL immediately as we only need the events- if sourceEL != nil {- _ = sourceEL.Close()- }-- // 3. Fork the events- newEvents := make([]*proto.Event, 0, len(sourceEvents))- for _, e := range sourceEvents {- // Deep copy the event- newEvent := pbproto.Clone(e).(*proto.Event)- // Update SessionId for the new session- newEvent.SessionId = newSessionID-- if err := newEL.AppendEvent(ctx, newEvent); err != nil {- _ = newEL.Close()- return nil, fmt.Errorf("failed to append forked event: %w", err)- }-- newEvents = append(newEvents, newEvent)- }-- // 4. Construct base session- session := &Session{- id: newSessionID,- state: proto.State_STATE_UNSPECIFIED,- steps: []*Step{},- waitingAgents: make(map[string][]*proto.Content),- checkpointIDs: make(map[string]struct{}),- eventLog: newEL,- }-- // Reconstruct session from new events- // Session state will be set to the latest state from events- err = session.reconstructState(newEvents)- if err != nil {- _ = newEL.Close()- return nil, err- }-- // 5. Add new session to manager- sm.mu.Lock()- defer sm.mu.Unlock()-- _, ok := sm.sessions[newSessionID]- if ok {- _ = newEL.Close()- return nil, fmt.Errorf("failed to add new session to manager: %s", newSessionID)- }-- sm.sessions[newSessionID] = session- return session, nil-}--// Replay entries to rebuild state-func (s *Session) reconstructState(events []*proto.Event) error {- for _, e := range events {- switch x := e.Kind.(type) {- case *proto.Event_AgentCallEvent:- event := x.AgentCallEvent- if event.AwaitingMore {- s.waitingAgents[event.Sender] = append(- s.waitingAgents[event.Sender], event.Contents...)- } else {- // Merge buffered and new contents into a single step.- contents := append(s.waitingAgents[event.Sender], event.Contents...)- if len(contents) > 0 {- s.steps = append(s.steps, &Step{- AgentID: event.Sender,- Contents: contents,- })- }-- // Cleanup the waiting buffer, it's now a part of the overall history.- delete(s.waitingAgents, event.Sender)- }- case *proto.Event_SessionStateEvent:- s.state = x.SessionStateEvent.State- case *proto.Event_HandoffEvent:- // TODO: Visit this section when resuming the waiting agents.- default:- return fmt.Errorf("unknown event kind: %v", e.Kind)- }-- if e.CheckpointId != "" {- s.checkpointIDs[e.CheckpointId] = struct{}{}- }- }- return nil-}--// GetSession retrieves a session by ID.-func (sm *SessionManager) GetSession(sessionID string) (*Session, error) {- sm.mu.RLock()- defer sm.mu.RUnlock()-- session, ok := sm.sessions[sessionID]- if !ok {- return nil, fmt.Errorf("session %s not found", sessionID)- }-- return session, nil-}--// CloseSession closes a session and its event log.-func (sm *SessionManager) CloseSession(sessionID string) error {- sm.mu.Lock()- defer sm.mu.Unlock()-- session, ok := sm.sessions[sessionID]- if !ok {- return fmt.Errorf("session %s not found", sessionID)- }-- if err := session.eventLog.Close(); err != nil {- return fmt.Errorf("failed to close event log: %w", err)- }-- delete(sm.sessions, sessionID)- return nil-}--// CloseAll closes all active sessions.-func (sm *SessionManager) CloseAll() {- sm.mu.Lock()- defer sm.mu.Unlock()-- for sessionID, session := range sm.sessions {- if err := session.eventLog.Close(); err != nil {- // Log error but continue closing other sessions- _ = err- }- delete(sm.sessions, sessionID)- }-}--func (s *Session) WriteAgentHandoff(ctx context.Context, source, target string) error {- s.mu.Lock()- defer s.mu.Unlock()-- return s.eventLog.AppendEvent(ctx, &proto.Event{- SessionId: s.id,- SenderId: source,- Timestamp: timestamppb.Now(),- ControllerTimestamp: timestamppb.Now(),- Kind: &proto.Event_HandoffEvent{- HandoffEvent: &proto.HandoffEvent{- SourceAgentId: source,- TargetAgentId: target,- },- },- })-}--// WriteContent appends an incoming content message to the session.-// Creates a checkpoint only if checkpoint_id is provided in the content.-func (s *Session) WriteContent(ctx context.Context, sender string, checkpointID string, contents []*proto.Content) error {- s.mu.Lock()- defer s.mu.Unlock()-- if checkpointID != "" {- if _, ok := s.checkpointIDs[checkpointID]; ok {- return fmt.Errorf("checkpoint %s already exists", checkpointID)- }- }-- if err := s.eventLog.AppendEvent(ctx, &proto.Event{- SessionId: s.id,- CheckpointId: checkpointID,- SenderId: sender,- Timestamp: timestamppb.Now(),- ControllerTimestamp: timestamppb.Now(),- Kind: &proto.Event_AgentCallEvent{- AgentCallEvent: &proto.AgentCallEvent{- Sender: sender,- AwaitingMore: false,- Contents: contents,- },- },- }); err != nil {- return err- }-- if len(contents) > 0 {- s.steps = append(s.steps, &Step{- AgentID: sender,- Contents: contents,- })- }- if checkpointID != "" {- s.checkpointIDs[checkpointID] = struct{}{}- }- return nil-}--// SetState updates the session state.-func (s *Session) SetState(ctx context.Context, state proto.State) error {- s.mu.Lock()- defer s.mu.Unlock()-- if err := s.eventLog.AppendEvent(ctx, &proto.Event{- SessionId: s.id,- Timestamp: timestamppb.Now(),- ControllerTimestamp: timestamppb.Now(),- Kind: &proto.Event_SessionStateEvent{- SessionStateEvent: &proto.SessionStateEvent{- State: state,- },- },- }); err != nil {- return err- }-- s.state = state- return nil-}--func (s *Session) WaitingAgents() []string {- s.mu.RLock()- defer s.mu.RUnlock()-- var agents []string- for agentID := range s.waitingAgents {- agents = append(agents, agentID)- }- return agents-}--func (s *Session) WaitingBuffer(agentID string) []*proto.Content {- s.mu.RLock()- defer s.mu.RUnlock()-- return s.waitingAgents[agentID]-}--func (s *Session) ID() string {- return s.id-}--func (s *Session) State() proto.State {- s.mu.RLock()- defer s.mu.RUnlock()-- return s.state-}--func (s *Session) History() []*proto.Content {- s.mu.RLock()- defer s.mu.RUnlock()-- var history []*proto.Content- for _, step := range s.steps {- history = append(history, step.Contents...)- }- return history-}--func (s *Session) ConfirmationWaitingAgent(confirmationID string) string {- s.mu.RLock()- defer s.mu.RUnlock()-- for i := len(s.steps) - 1; i >= 0; i-- {- step := s.steps[i]- for _, content := range step.Contents {- conf := content.GetConfirmation()- if conf != nil && conf.Id == confirmationID && conf.Question != "" {- return step.AgentID- }- }- }- return ""-}diff --git a/internal/controller/session_test.go b/internal/controller/session_test.godeleted file mode 100644index 2c24310..0000000--- a/internal/controller/session_test.go+++ /dev/null@@ -1,188 +0,0 @@-// Copyright 2026 Google LLC-//-// Licensed under the Apache License, Version 2.0 (the "License");-// you may not use this file except in compliance with the License.-// You may obtain a copy of the License at-//-// http://www.apache.org/licenses/LICENSE-2.0-//-// Unless required by applicable law or agreed to in writing, software-// distributed under the License is distributed on an "AS IS" BASIS,-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-// See the License for the specific language governing permissions and-// limitations under the License.--package controller--import (- "context"- "fmt"- "sync"- "testing"-- "github.com/google/gar/internal/eventlog"- "github.com/google/gar/proto"-)--// MockEventLog implements eventlog.EventLog for testing.-type MockEventLog struct {- sessionID string- events []*proto.Event- mu sync.Mutex- closed bool-}--func (m *MockEventLog) AppendEvent(ctx context.Context, e *proto.Event) error {- m.mu.Lock()- defer m.mu.Unlock()- if m.closed {- return fmt.Errorf("log closed")- }- m.events = append(m.events, e)- return nil-}--func (m *MockEventLog) LoadEvents(ctx context.Context, checkpointID string) ([]*proto.Event, proto.State, error) {- m.mu.Lock()- defer m.mu.Unlock()-- var events []*proto.Event- var state proto.State- for _, e := range m.events {- switch x := e.Kind.(type) {- case *proto.Event_SessionStateEvent:- state = x.SessionStateEvent.State- }- events = append(events, e)- if checkpointID != "" && e.CheckpointId == checkpointID {- break- }- }- return events, state, nil-}--func (m *MockEventLog) Close() error {- m.mu.Lock()- defer m.mu.Unlock()- m.closed = true- return nil-}--func (m *MockEventLog) SessionID() string {- return m.sessionID-}--func TestSessionManager_ForkSession_Success(t *testing.T) {- ctx := context.Background()-- // Create a storage for mocks to simulate persistence- storage := make(map[string]*MockEventLog)- factory := func(sessionID string) (eventlog.EventLog, error) {- if el, ok := storage[sessionID]; ok {- return el, nil- }- el := &MockEventLog{sessionID: sessionID}- storage[sessionID] = el- return el, nil- }-- sm := &SessionManager{- sessions: make(map[string]*Session),- eventLogBuilder: factory,- }-- sourceID := "source"- checkpointID := "cp1"- newID := "fork"-- // Setup source session with events- sourceEL, _ := factory(sourceID)- sourceEvents := []*proto.Event{- {SessionId: sourceID, CheckpointId: checkpointID, Kind: &proto.Event_AgentCallEvent{AgentCallEvent: &proto.AgentCallEvent{Contents: []*proto.Content{{Role: "user"}}}}},- {SessionId: sourceID, Kind: &proto.Event_SessionStateEvent{SessionStateEvent: &proto.SessionStateEvent{State: proto.State_STATE_COMPLETED}}},- }- for _, e := range sourceEvents {- sourceEL.AppendEvent(ctx, e)- }-- // Fork- session, err := sm.ForkSession(ctx, sourceID, checkpointID, newID)- if err != nil {- t.Fatalf("ForkSession failed: %v", err)- }-- if session.ID() != newID {- t.Errorf("expected session ID %s, got %s", newID, session.ID())- }-- // Verify events were replayed to new ID- forkEL := storage[newID]- if len(forkEL.events) != 1 { // Only one event up to checkpoint- t.Errorf("expected 1 event replayed, got %d", len(forkEL.events))- }- if forkEL.events[0].SessionId != newID {- t.Errorf("expected replayed event to have session ID %s, got %s", newID, forkEL.events[0].SessionId)- }-}--func TestSessionManager_ForkSession_Concurrent(t *testing.T) {- // Test if multiple concurrent forks to the same ID handle memory lock correctly- ctx := context.Background()- storage := make(map[string]*MockEventLog)- var mu sync.Mutex- factory := func(sessionID string) (eventlog.EventLog, error) {- mu.Lock()- defer mu.Unlock()- if el, ok := storage[sessionID]; ok {- return el, nil- }- el := &MockEventLog{sessionID: sessionID}- storage[sessionID] = el- return el, nil- }-- sm := &SessionManager{- sessions: make(map[string]*Session),- eventLogBuilder: factory,- }-- sourceID := "source"- newID := "shared-fork"-- // Setup source- sourceEL, _ := factory(sourceID)- sourceEL.AppendEvent(ctx,- &proto.Event{- SessionId: sourceID,- Kind: &proto.Event_AgentCallEvent{AgentCallEvent: &proto.AgentCallEvent{}},- })-- // Run multiple forks concurrently- var wg sync.WaitGroup- errs := make(chan error, 10)- for i := 0; i < 10; i++ {- wg.Add(1)- go func() {- defer wg.Done()- _, err := sm.ForkSession(ctx, sourceID, "", newID)- if err != nil {- errs <- err- }- }()- }- wg.Wait()- close(errs)-- successCount := 0- collisionCount := 0- for err := range errs {- if err != nil {- collisionCount++- }- }- successCount = 10 - collisionCount-- if successCount != 1 {- t.Errorf("expected exactly 1 successful fork, got %d", successCount)- }-}diff --git a/internal/controller/task/eventlog.go b/internal/controller/task/eventlog.gonew file mode 100644index 0000000..780936b--- /dev/null+++ b/internal/controller/task/eventlog.go@@ -0,0 +1,117 @@+// Copyright 2026 Google LLC+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package task++import (+ "bufio"+ "context"+ "fmt"+ "os"+ "sync"++ "github.com/google/gar/proto"+ "google.golang.org/protobuf/encoding/protojson"+)++// EventLog is the persistent, append-only record of all actions taken in an+// exec. Every entry is an atomic step: replaying the log in order brings+// the executor back to a consistent state from which execution can resume.+type EventLog interface {+ // Append adds an event to the end of the log.+ // Implementations must be safe for concurrent use.+ Append(ctx context.Context, event *proto.ExecutionEvent) error++ // Events returns all events recorded so far, in append order.+ Events(ctx context.Context) ([]*proto.ExecutionEvent, error)++ // Close releases the underlying resources and closes the log.+ Close() error+}++// FileEventLog is a durable EventLog that writes one JSON object per line to+// a file. Each session should use its own file. The file is created if it does+// not exist and is opened for appending, so existing events survive restarts.+//+// The format is newline-delimited JSON (NDJSON): every Append call writes one+// complete JSON object followed by a newline, making both concurrent writes+// and crash recovery safe.+type FileEventLog struct {+ mu sync.Mutex+ path string+ f *os.File+}++// OpenFileEventLog opens (or creates) the log file at path.+// Call Close when the session is done to release the file handle.+func OpenFileEventLog(path string) (*FileEventLog, error) {+ f, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o644)+ if err != nil {+ return nil, fmt.Errorf("eventlog: open %s: %w", path, err)+ }+ return &FileEventLog{path: path, f: f}, nil+}++var marshalOpts = protojson.MarshalOptions{UseProtoNames: true}+var unmarshalOpts = protojson.UnmarshalOptions{DiscardUnknown: true}++// Append serialises event as a single JSON line and syncs to disk.+func (l *FileEventLog) Append(_ context.Context, event *proto.ExecutionEvent) error {+ line, err := marshalOpts.Marshal(event)+ if err != nil {+ return fmt.Errorf("eventlog: marshal: %w", err)+ }++ l.mu.Lock()+ defer l.mu.Unlock()++ if _, err := l.f.Write(append(line, '\n')); err != nil {+ return fmt.Errorf("eventlog: write %s: %w", l.path, err)+ }+ // Sync after every write so a crash does not leave a partial line.+ return l.f.Sync()+}++// Events reads all complete JSON lines from the beginning of the file.+func (l *FileEventLog) Events(_ context.Context) ([]*proto.ExecutionEvent, error) {+ l.mu.Lock()+ defer l.mu.Unlock()++ if _, err := l.f.Seek(0, 0); err != nil {+ return nil, fmt.Errorf("eventlog: seek %s: %w", l.path, err)+ }++ var events []*proto.ExecutionEvent+ scanner := bufio.NewScanner(l.f)+ for scanner.Scan() {+ line := scanner.Bytes()+ if len(line) == 0 {+ continue+ }+ ev := &proto.ExecutionEvent{}+ if err := unmarshalOpts.Unmarshal(line, ev); err != nil {+ // Skip lines that could not be decoded (e.g. truncated by crash).+ continue+ }+ events = append(events, ev)+ }+ return events, scanner.Err()+}++// Close releases the underlying file handle.+func (l *FileEventLog) Close() error {+ l.mu.Lock()+ defer l.mu.Unlock()+ return l.f.Close()+}diff --git a/internal/controller/task/task.go b/internal/controller/task/task.gonew file mode 100644index 0000000..c4d9ff0--- /dev/null+++ b/internal/controller/task/task.go@@ -0,0 +1,203 @@+// Copyright 2026 Google LLC+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package task++import (+ "context"+ "errors"++ "github.com/google/gar/agent"+ "github.com/google/gar/proto"+ "google.golang.org/protobuf/types/known/timestamppb"+)++type EventLogBuilder func(taskID string) (EventLog, error)++type taskExecutor struct {+ id string+ elBuilder EventLogBuilder+ registry map[string]agent.Agent+}++func newTaskID(parent, child string) string {+ if parent == "" {+ return child+ }+ return parent + "-" + child+}++func DefaultExecutor(b EventLogBuilder, registry map[string]agent.Agent) agent.TaskExecutor {+ return &taskExecutor{+ id: "",+ elBuilder: b,+ registry: registry,+ }+}++func (tm *taskExecutor) Exec(ctx context.Context, t *agent.Task, o agent.OutputHandler) error {+ t.ID = newTaskID(tm.id, t.ID)+ el, err := tm.elBuilder(t.ID)+ if err != nil {+ return err+ }++ a, ok := tm.registry[t.AgentID]+ if !ok {+ return errors.New("no agent found")+ }++ allInputs, state, err := history(ctx, el, t.ID)+ if err != nil {+ return err+ }++ if state == proto.State_STATE_COMPLETED {+ if t.Rehydrate {+ return o(&proto.ProcessResponse{+ Contents: allInputs,+ FromCache: true,+ })+ }+ return nil+ }+ return tm.exec(ctx, t, el, a, allInputs, o)+}++func (tm *taskExecutor) exec(+ ctx context.Context,+ t *agent.Task,+ el EventLog,+ a agent.Agent,+ allInputs []*proto.Content,+ o agent.OutputHandler) error {+ child := &taskExecutor{+ id: t.ID,+ elBuilder: tm.elBuilder,+ registry: tm.registry,+ }+ defer el.Close()++ var allOutputs []*proto.Content+ outputBuffer := func(outgoing *proto.ProcessResponse) error {+ allOutputs = append(allOutputs, outgoing.Contents...)+ if o != nil {+ return o(outgoing)+ }+ return nil+ }++ allInputs = append(allInputs, t.Inputs...)+ if err := logPending(ctx, el, t); err != nil {+ return err+ }++ if len(allInputs) == 0 {+ return errors.New("no inputs")+ }++ if err := a.Process(ctx, &agent.Task{+ ID: t.ID,+ AgentID: t.AgentID,+ Inputs: allInputs,+ }, child, outputBuffer); err != nil {+ _ = logFailed(ctx, el, t) // Attempt to log failure, but prioritize returning the original error.+ return err+ }++ if len(allOutputs) > 0 {+ // Log all the outputs at once.+ // TODO: Log only at checkpoints.+ if err := logOutputs(ctx, el, t, allOutputs); err != nil {+ return err+ }++ last := allOutputs[len(allOutputs)-1]+ if last.GetConfirmation() == nil || last.GetConfirmation().GetQuestion() == "" {+ // Log completed only if we are not waiting+ // for an answer to a confirmation.+ return logCompleted(ctx, el, t)+ }+ }+ return nil+}++func history(ctx context.Context, el EventLog, taskID string) ([]*proto.Content, proto.State, error) {+ events, err := el.Events(ctx)+ if err != nil {+ return nil, proto.State_STATE_UNSPECIFIED, err+ }++ var history []*proto.Content+ var state proto.State++ for _, event := range events {+ if event.TaskId != taskID {+ continue+ }+ // Reset after the status change ensure+ // that we have a clean state even if we are+ // presented an event log with dirty entries+ // from previous runs.+ if event.State == proto.State_STATE_PENDING {+ history = []*proto.Content{}+ }+ history = append(history, event.Inputs...)+ history = append(history, event.Outputs...)+ state = event.State+ }++ if state == proto.State_STATE_COMPLETED || state == proto.State_STATE_FAILED {+ return history, state, nil+ }++ return history, state, nil+}++func logPending(ctx context.Context, el EventLog, t *agent.Task) error {+ return el.Append(ctx, &proto.ExecutionEvent{+ Timestamp: timestamppb.Now(),+ TaskId: t.ID,+ AgentId: t.AgentID,+ Inputs: t.Inputs,+ State: proto.State_STATE_PENDING,+ })+}++func logFailed(ctx context.Context, el EventLog, t *agent.Task) error {+ return el.Append(ctx, &proto.ExecutionEvent{+ Timestamp: timestamppb.Now(),+ TaskId: t.ID,+ AgentId: t.AgentID,+ State: proto.State_STATE_FAILED,+ })+}++func logCompleted(ctx context.Context, el EventLog, t *agent.Task) error {+ return el.Append(ctx, &proto.ExecutionEvent{+ Timestamp: timestamppb.Now(),+ TaskId: t.ID,+ AgentId: t.AgentID,+ State: proto.State_STATE_COMPLETED,+ })+}++func logOutputs(ctx context.Context, el EventLog, t *agent.Task, outputs []*proto.Content) error {+ return el.Append(ctx, &proto.ExecutionEvent{+ Timestamp: timestamppb.Now(),+ TaskId: t.ID,+ AgentId: t.AgentID,+ Outputs: outputs,+ })+}diff --git a/internal/controller/task/task_test.go b/internal/controller/task/task_test.gonew file mode 100644index 0000000..a8f4edd--- /dev/null+++ b/internal/controller/task/task_test.go@@ -0,0 +1,363 @@+// Copyright 2026 Google LLC+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package task++import (+ "context"+ "fmt"+ "log"+ "sync"+ "sync/atomic"+ "testing"+ "time"++ "github.com/google/gar/agent"+ "github.com/google/gar/proto"+ "golang.org/x/sync/errgroup"+)++// MemoryEventLog is an in-memory EventLog useful for testing and short-lived+// executions. It does not survive process restarts.+type MemoryEventLog struct {+ mu sync.Mutex+ events []*proto.ExecutionEvent+}++func (m *MemoryEventLog) Append(_ context.Context, event *proto.ExecutionEvent) error {+ m.mu.Lock()+ defer m.mu.Unlock()++ m.events = append(m.events, event)+ return nil+}++func (m *MemoryEventLog) Events(_ context.Context) ([]*proto.ExecutionEvent, error) {+ m.mu.Lock()+ defer m.mu.Unlock()++ out := make([]*proto.ExecutionEvent, len(m.events))+ copy(out, m.events)+ return out, nil+}++// Drop removes every event for which drop returns true.+// It is provided for testing and crash-simulation purposes.+func (m *MemoryEventLog) Drop(drop func(*proto.ExecutionEvent) bool) {+ m.mu.Lock()+ defer m.mu.Unlock()++ kept := m.events[:0]+ for _, ev := range m.events {+ if !drop(ev) {+ kept = append(kept, ev)+ }+ }+ m.events = kept+}++func (m *MemoryEventLog) Close() error {+ return nil+}++// memoryBuilder returns a new EventLogBuilder that creates a fresh MemoryEventLog per task.+func memoryBuilder() EventLogBuilder {+ return func(taskID string) (EventLog, error) {+ return &MemoryEventLog{}, nil+ }+}++func Example() {+ ctx := context.Background()++ registry := map[string]agent.Agent{+ "planner": AgentFunc(func(inputs []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler) {+ if err := tm.Exec(ctx, &agent.Task{+ ID: "deep-research-task",+ AgentID: "deep-research",+ Inputs: inputs,+ }, o); err != nil {+ return+ }++ if err := tm.Exec(ctx, &agent.Task{+ ID: "pub-med-lookup-task",+ AgentID: "pub-med-index",+ Inputs: inputs,+ }, o); err != nil {+ return+ }+ }),+ }++ tm := DefaultExecutor(memoryBuilder(), registry)+ if err := tm.Exec(ctx, &agent.Task{+ ID: "test",+ AgentID: "planner",+ Inputs: []*proto.Content{text("user", "Hello, I'd like to research cancer treatment options.")},+ }, nil); err != nil {+ log.Fatal(err)+ }+}++func TestTaskManager(t *testing.T) {+ ctx := context.Background()++ registry := map[string]agent.Agent{+ "root": AgentFunc(func(inputs []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler) {+ if err := tm.Exec(ctx, &agent.Task{+ ID: "child-task",+ AgentID: "child",+ Inputs: inputs,+ }, o); err != nil {+ t.Fatal(err)+ }+ if o != nil {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{text("assistant", "root done")},+ })+ }+ }),+ "child": AgentFunc(func(inputs []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler) {+ time.Sleep(100 * time.Millisecond)+ if o != nil {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{text("assistant", "child done")},+ })+ }+ }),+ }++ tm := DefaultExecutor(memoryBuilder(), registry)+ if err := tm.Exec(ctx, &agent.Task{+ ID: "root-task",+ AgentID: "root",+ Inputs: []*proto.Content{text("user", "hello!")},+ }, nil); err != nil {+ t.Fatal(err)+ }+}++func TestFanout(t *testing.T) {+ ctx := context.Background()++ var executions atomic.Int32+ registry := map[string]agent.Agent{+ "root": AgentFunc(func(inputs []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler) {+ var g errgroup.Group+ for i := 0; i < 50; i++ {+ i := i // Capture loop variable.+ g.Go(func() error {+ return tm.Exec(ctx, &agent.Task{+ ID: fmt.Sprintf("child-%d", i),+ AgentID: "child",+ Inputs: inputs,+ }, nil)+ })+ }+ if err := g.Wait(); err != nil {+ t.Fatal(err)+ }+ if o != nil {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{text("assistant", "root done")},+ })+ }+ }),+ "child": AgentFunc(func(inputs []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler) {+ executions.Add(1)+ time.Sleep(100 * time.Millisecond)++ var g errgroup.Group+ for i := 0; i < 2; i++ {+ i := i // Capture loop variable.+ g.Go(func() error {+ return tm.Exec(ctx, &agent.Task{+ ID: fmt.Sprintf("child2-%d", i),+ AgentID: "child2",+ Inputs: inputs,+ }, nil)+ })+ }+ if err := g.Wait(); err != nil {+ t.Fatal(err)+ }+ if o != nil {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{text("assistant", "child done")},+ })+ }+ }),+ "child2": AgentFunc(func(inputs []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler) {+ executions.Add(1)+ time.Sleep(100 * time.Millisecond)+ if o != nil {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{text("assistant", "child2 done")},+ })+ }+ }),+ }++ tm := DefaultExecutor(memoryBuilder(), registry)+ if err := tm.Exec(ctx, &agent.Task{+ ID: "root-task",+ AgentID: "root",+ Inputs: []*proto.Content{text("user", "hello!")},+ }, nil); err != nil {+ t.Fatal(err)+ }++ if got, want := executions.Load(), int32(150); got != want {+ t.Fatalf("executions got %v; want %v", got, want)+ }+}++func TestConfirmation(t *testing.T) {+ ctx := context.Background()++ var runCount int+ logs := map[string]*MemoryEventLog{}+ var logsMu sync.Mutex+ builder := func(taskID string) (EventLog, error) {+ logsMu.Lock()+ defer logsMu.Unlock()+ if l, ok := logs[taskID]; ok {+ return l, nil+ }+ l := &MemoryEventLog{}+ logs[taskID] = l+ return l, nil+ }++ confID := "test-conf-id"+ var childDone atomic.Bool+ registry := map[string]agent.Agent{+ "root": AgentFunc(func(inputs []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler) {+ if err := tm.Exec(ctx, &agent.Task{+ ID: "child-task",+ AgentID: "child",+ Inputs: inputs,+ }, o); err != nil {+ t.Fatal(err)+ }+ }),+ "child": AgentFunc(func(inputs []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler) {+ if runCount == 0 {+ runCount+++ log.Println("Asking for the question...")+ if o != nil {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Content: &proto.Content_Confirmation{+ Confirmation: &proto.ConfirmationContent{Id: confID, Question: "proceed?"},+ },+ }},+ })+ }+ return+ }++ lastInput := inputs[len(inputs)-1]+ if lastInput.GetConfirmation() == nil || lastInput.GetConfirmation().GetDecision() == nil {+ t.Fatal("no decision in the incoming inputs")+ }++ childDone.Store(true)+ if o != nil {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{text("assistant", "child done")},+ })+ }+ }),+ }++ tm := DefaultExecutor(builder, registry)++ // First run: child returns a confirmation request.+ if err := tm.Exec(ctx, &agent.Task{+ ID: "root-task",+ AgentID: "root",+ Inputs: []*proto.Content{text("user", "hello!")},+ }, nil); err != nil {+ t.Fatal(err)+ }++ // Re-run with the approval decision as new input.+ approval := &proto.Content{+ Role: "user",+ Content: &proto.Content_Confirmation{+ Confirmation: &proto.ConfirmationContent{+ Id: confID,+ Decision: &proto.ConfirmationContent_Approval{+ Approval: &proto.ApprovalDecision{Approved: true},+ },+ },+ },+ }+ if err := tm.Exec(ctx, &agent.Task{+ ID: "root-task",+ AgentID: "root",+ Inputs: []*proto.Content{approval},+ }, nil); err != nil {+ t.Fatal(err)+ }++ if !childDone.Load() {+ t.Fatal("child is not done")+ }+}++func TestResume(t *testing.T) {+ ctx := context.Background()+ dir := t.TempDir()++ builder := func(taskID string) (EventLog, error) {+ return OpenFileEventLog(dir + "/test-resume-" + taskID + ".jsonl")+ }++ registry := map[string]agent.Agent{+ "root": AgentFunc(func(inputs []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler) {+ if err := tm.Exec(ctx, &agent.Task{+ ID: "child-task",+ AgentID: "child",+ Inputs: inputs,+ }, nil); err != nil {+ t.Fatal(err)+ }+ if o != nil {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{text("assistant", "root done")},+ })+ }+ }),+ "child": AgentFunc(func(inputs []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler) {+ time.Sleep(100 * time.Millisecond)+ if o != nil {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{text("assistant", "child done")},+ })+ }+ }),+ }++ tm := DefaultExecutor(builder, registry)+ if err := tm.Exec(ctx, &agent.Task{+ ID: "root-task",+ AgentID: "root",+ Inputs: []*proto.Content{text("user", "hello!")},+ }, nil); err != nil {+ t.Fatal(err)+ }+}diff --git a/internal/controller/task/util.go b/internal/controller/task/util.gonew file mode 100644index 0000000..63f1c4d--- /dev/null+++ b/internal/controller/task/util.go@@ -0,0 +1,45 @@+// Copyright 2026 Google LLC+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package task++import (+ "context"++ "github.com/google/gar/agent"+ "github.com/google/gar/proto"+)++// agentFunc adapts a simple string→string function into the agent.Agent interface.+type agentFunc func(input []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler)++func (f agentFunc) Process(ctx context.Context, t *agent.Task, tm agent.TaskExecutor, o agent.OutputHandler) error {+ f(t.Inputs, tm, o)+ return nil+}++func (f agentFunc) HealthCheck(_ context.Context) error { return nil }+func (f agentFunc) Close() error { return nil }++func AgentFunc(fn func(input []*proto.Content, tm agent.TaskExecutor, o agent.OutputHandler)) agent.Agent {+ return agentFunc(fn)+}++// text is a helper that builds a plain-text Content.+func text(role, s string) *proto.Content {+ return &proto.Content{+ Content: &proto.Content_Text{Text: &proto.TextContent{Text: s}},+ Role: role,+ }+}diff --git a/internal/eventlog/eventlog.go b/internal/eventlog/eventlog.godeleted file mode 100644index 5f8442f..0000000--- a/internal/eventlog/eventlog.go+++ /dev/null@@ -1,43 +0,0 @@-// Copyright 2026 Google LLC-//-// Licensed under the Apache License, Version 2.0 (the "License");-// you may not use this file except in compliance with the License.-// You may obtain a copy of the License at-//-// http://www.apache.org/licenses/LICENSE-2.0-//-// Unless required by applicable law or agreed to in writing, software-// distributed under the License is distributed on an "AS IS" BASIS,-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-// See the License for the specific language governing permissions and-// limitations under the License.--// Package eventlog implements event logging for session durability.-// Event log entries use JSON Lines format with one log file per session.-package eventlog--import (- "context"-- "github.com/google/gar/proto"-)--// EventLog is the interface that all event log implementations must satisfy.-// It provides methods for appending events, reading entries, and managing the log lifecycle.-type EventLog interface {- // AppendEvent appends an event to the log.- AppendEvent(ctx context.Context, e *proto.Event) error-- // LoadEvents loads all events up to the checkpoint.- // If no checkpoint is provided, it returns all events recorded.- LoadEvents(ctx context.Context, checkpointID string) ([]*proto.Event, proto.State, error)-- // Close closes the event log and releases any resources.- Close() error-- // SessionID returns the session ID for this event log.- SessionID() string-}--// EventLogBuilder is a function that creates EventLog instances for sessions.-type EventLogBuilder func(sessionID string) (EventLog, error)diff --git a/internal/eventlog/file.go b/internal/eventlog/file.godeleted file mode 100644index 5beae0e..0000000--- a/internal/eventlog/file.go+++ /dev/null@@ -1,180 +0,0 @@-// Copyright 2026 Google LLC-//-// Licensed under the Apache License, Version 2.0 (the "License");-// you may not use this file except in compliance with the License.-// You may obtain a copy of the License at-//-// http://www.apache.org/licenses/LICENSE-2.0-//-// Unless required by applicable law or agreed to in writing, software-// distributed under the License is distributed on an "AS IS" BASIS,-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-// See the License for the specific language governing permissions and-// limitations under the License.--package eventlog--import (- "bufio"- "context"- "fmt"- "os"- "path/filepath"- "sync"-- "github.com/google/gar/proto"- "google.golang.org/protobuf/encoding/protojson"-)--// FileEventLog represents a file-based event log for a single session.-// It provides append-only durability with JSON Lines format.-type FileEventLog struct {- mu sync.Mutex- sessionID string- filePath string- file *os.File- writer *bufio.Writer-}--// FileConfig configures a FileEventLog instance.-type FileConfig struct {- SessionID string- Dir string // Directory where event log files are stored-}--// NewFileEventLog creates a new file-based EventLog instance for the given session.-// It creates the event log directory and file if they don't exist.-func NewFileEventLog(config FileConfig) (*FileEventLog, error) {- if config.SessionID == "" {- return nil, fmt.Errorf("session ID cannot be empty")- }- if config.Dir == "" {- config.Dir = "eventlog"- }-- // Create event log directory if it doesn't exist- if err := os.MkdirAll(config.Dir, 0755); err != nil {- return nil, fmt.Errorf("failed to create event log directory: %w", err)- }-- filePath := filepath.Join(config.Dir, fmt.Sprintf("%s.log", config.SessionID))-- // Open file in append mode, create if doesn't exist- file, err := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)- if err != nil {- return nil, fmt.Errorf("failed to open event log file: %w", err)- }-- return &FileEventLog{- sessionID: config.SessionID,- filePath: filePath,- file: file,- writer: bufio.NewWriter(file),- }, nil-}--// NewFileConfig creates a new file-based EventLog instance for the given session.-// This is a convenience function that wraps NewFileEventLog.-// Deprecated: Use NewFileEventLog for clarity, or implement your own EventLog.-func NewFileConfig(config FileConfig) (EventLog, error) {- return NewFileEventLog(config)-}--func (e *FileEventLog) AppendEvent(ctx context.Context, event *proto.Event) error {- e.mu.Lock()- defer e.mu.Unlock()-- jsonData, err := protojson.Marshal(event)- if err != nil {- return fmt.Errorf("failed to marshal entry: %w", err)- }- if _, err := e.writer.Write(jsonData); err != nil {- return fmt.Errorf("failed to write entry: %w", err)- }- if _, err := e.writer.WriteString("\n"); err != nil {- return fmt.Errorf("failed to write newline: %w", err)- }-- // Flush to ensure durability- if err := e.writer.Flush(); err != nil {- return fmt.Errorf("failed to flush: %w", err)- }- if err := e.file.Sync(); err != nil {- return fmt.Errorf("failed to sync: %w", err)- }- return nil-}--func (e *FileEventLog) LoadEvents(ctx context.Context, checkpointID string) ([]*proto.Event, proto.State, error) {- e.mu.Lock()- defer e.mu.Unlock()-- var state proto.State- if err := e.writer.Flush(); err != nil {- return nil, 0, fmt.Errorf("failed to flush before reading: %w", err)- }-- f, err := os.Open(e.filePath)- if err != nil {- return nil, 0, fmt.Errorf("failed to open event log file for reading: %w", err)- }- defer f.Close()-- var events []*proto.Event- scanner := bufio.NewScanner(f)- var buf = make([]byte, 1024*1024) // initial 1MB- scanner.Buffer(buf, 8*1024*1024) // max 8MB- checkpointFound := false-- for scanner.Scan() {- line := scanner.Bytes()-- var e proto.Event- if err := protojson.Unmarshal(line, &e); err != nil {- return nil, 0, fmt.Errorf("failed to unmarshal event: %w", err)- }-- switch x := e.Kind.(type) {- case *proto.Event_SessionStateEvent:- state = x.SessionStateEvent.State- }- events = append(events, &e)- if checkpointID != "" && e.CheckpointId == checkpointID {- checkpointFound = true- break- }- }- if err := scanner.Err(); err != nil {- return nil, 0, fmt.Errorf("error reading event log file: %w", err)- }- if checkpointID != "" && !checkpointFound {- return nil, 0, fmt.Errorf("checkpoint ID %s not found in event log", checkpointID)- }-- return events, state, nil-}--// Close closes the event log file.-func (e *FileEventLog) Close() error {- e.mu.Lock()- defer e.mu.Unlock()-- if err := e.writer.Flush(); err != nil {- return fmt.Errorf("failed to flush on close: %w", err)- }- if err := e.file.Close(); err != nil {- return fmt.Errorf("failed to close file: %w", err)- }- return nil-}--// FilePath returns the path to the event log file.-// This method is specific to FileEventLog and not part of the EventLog interface.-func (e *FileEventLog) FilePath() string {- return e.filePath-}--// SessionID returns the session ID for this event log.-func (e *FileEventLog) SessionID() string {- return e.sessionID-}diff --git a/internal/historyutil/confirmations.go b/internal/historyutil/confirmations.gonew file mode 100644index 0000000..de66dc9--- /dev/null+++ b/internal/historyutil/confirmations.go@@ -0,0 +1,66 @@+// Copyright 2026 Google LLC+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package historyutil++import "github.com/google/gar/proto"++// WaitsForConfirmation returns true if the last message in the history+// is a confirmation question waiting for user input.+func WaitsForConfirmation(history []*proto.Content) bool {+ if len(history) == 0 {+ return false+ }+ last := history[len(history)-1]+ if last.GetConfirmation() != nil && last.GetConfirmation().Question != "" {+ return true+ }+ return false+}++// HasConfirmationAnswer returns true if the last message in the history+// is a confirmation question waiting for user input.+func HasConfirmationAnswer(history []*proto.Content) (approved bool, conf *proto.ConfirmationContent) {+ if len(history) == 0 {+ return false, nil+ }+ last := history[len(history)-1]+ if last.GetConfirmation() == nil {+ return false, nil+ }+ if last.GetConfirmation().GetApproval() != nil {+ conf = last.GetConfirmation()+ approved = true+ }+ if last.GetConfirmation().GetDecline() != nil {+ conf = last.GetConfirmation()+ approved = false+ }+ return approved, conf+}++func WaitsForUser(history []*proto.Content) bool {+ if len(history) == 0 {+ return false+ }+ if WaitsForConfirmation(history) {+ return true+ }++ last := history[len(history)-1]+ if last.GetConfirmation() != nil && last.GetConfirmation().GetDecline() != nil {+ return true+ }+ return false+}diff --git a/internal/server/server.go b/internal/server/server.goindex ab00b2d..aec5940 100644--- a/internal/server/server.go+++ b/internal/server/server.go@@ -50,28 +50,18 @@ func (s *Server) TriggerSession(req *proto.TriggerSessionRequest, stream grpc.SesessionID := req.SessionIdinputs := req.Inputs- // TODO(jbd): This state update should be sent directly from the controller.- if err := stream.Send(&proto.TriggerSessionResponse{- State: proto.State_STATE_RUNNING,- SessionId: sessionID,- }); err != nil {- return err- }-incoming := &proto.ProcessRequest{Contents: inputs,}// Create output handler to stream outputs back to clientoutputHandler := agent.OutputHandler(func(outgoing *proto.ProcessResponse) error {return stream.Send(&proto.TriggerSessionResponse{- SessionId: sessionID,- CheckpointId: outgoing.CheckpointId,- Outputs: outgoing.Contents,- State: proto.State_STATE_RUNNING,+ SessionId: sessionID,+ Outputs: outgoing.Contents,})})return s.controller.TriggerSession(- stream.Context(), sessionID, incoming, outputHandler)+ stream.Context(), sessionID, req.AgentId, incoming, outputHandler)}func (s *Server) ForkSession(ctx context.Context, req *proto.ForkSessionRequest) (*proto.ForkSessionResponse, error) {diff --git a/internal/testagent/agent.go b/internal/testagent/agent.gonew file mode 100644index 0000000..f1ed4df--- /dev/null+++ b/internal/testagent/agent.go@@ -0,0 +1,357 @@+package testagent++import (+ "context"+ "crypto/rand"+ "encoding/hex"+ "fmt"+ "strings"+ "time"++ "github.com/google/gar/agent"+ "github.com/google/gar/internal/historyutil"+ "github.com/google/gar/proto"+ "github.com/google/uuid"+)++func Agents() map[string]agent.Agent {+ return map[string]agent.Agent{+ "coding": &CodingAgent{},+ "docker-build": &DockerBuilderAgent{},+ "docker-mirror": &DockerMirrorAgent{},+ "kubernetes-deploy": &KubernetesDeployAgent{},+ }+}++type CodingAgent struct{}++// Process handles processing of input content with callback handler.+func (a *CodingAgent) Process(ctx context.Context, t *agent.Task, e agent.TaskExecutor, o agent.OutputHandler) error {+ exec := NewExecutor(e, o)+ {+ exec.Append(&proto.Content{+ Role: "user",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "Generate Cloud Run Python server code. Only show Python code, the output should be deployable as a server. We will deploy it to Kubernetes.",+ },+ },+ })+ exec.Append(t.Inputs...)+ outputs, err := exec.Exec(ctx, &Execution{+ TaskID: "code",+ AgentID: "gemini",+ Inputs: exec.History(),+ })+ if err != nil {+ return err+ }+ exec.Append(outputs...)+ }++ {+ outputs, err := exec.Exec(ctx, &Execution{+ TaskID: "docker",+ AgentID: "docker-build",+ Inputs: exec.History(),+ })+ if err != nil {+ return err+ }+ exec.Append(outputs...)+ }++ {+ exec.Append(&proto.Content{+ Role: "user",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "Deploy to us-central1.",+ },+ },+ })+ exec.Append(t.Inputs...)+ outputs, err := exec.Exec(ctx, &Execution{+ TaskID: "deploy",+ AgentID: "kubernetes-deploy",+ Inputs: exec.History(),+ })+ if err != nil {+ return err+ }+ exec.Append(outputs...)+ // User may need to take control back to confirm+ // or after decline.+ if historyutil.WaitsForUser(exec.History()) {+ return nil+ }+ }++ {+ exec.Append(&proto.Content{+ Role: "user",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "Can you deploy it other regions, avoiding the us-central1?",+ },+ },+ })+ exec.Append(t.Inputs...)+ outputs, err := exec.Exec(ctx, &Execution{+ TaskID: "deploy-more",+ AgentID: "kubernetes-deploy",+ Inputs: exec.History(),+ })+ if err != nil {+ return err+ }+ exec.Append(outputs...)+ if historyutil.WaitsForUser(exec.History()) {+ return nil+ }+ }++ if err := o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "One last step, a summary...\n\n",+ },+ },+ }},+ }); err != nil {+ return err+ }++ {+ exec.Append(&proto.Content{+ Role: "user",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "Summarize what we did, and list links to the final deployment endpoints. Give instructions how to revert the deployments if needed",+ },+ },+ })+ _, err := exec.Exec(ctx, &Execution{+ TaskID: "summarize",+ AgentID: "gemini",+ Inputs: exec.History(),+ })+ if err != nil {+ return err+ }+ }++ return nil+}++// HealthCheck checks if the agent is healthy.+func (a *CodingAgent) HealthCheck(ctx context.Context) error {+ return nil+}++// Close gracefully shuts down the agent.+func (a *CodingAgent) Close() error {+ return nil+}++var pendingRegions = make(map[string][]string) // not for production++type KubernetesDeployAgent struct{}++func (a *KubernetesDeployAgent) Process(ctx context.Context, t *agent.Task, e agent.TaskExecutor, o agent.OutputHandler) error {+ exec := NewExecutor(e, o)++ approved, conf := historyutil.HasConfirmationAnswer(t.Inputs)+ if conf != nil && pendingRegions[conf.Id] != nil {+ if !approved {+ return nil+ }++ regions := pendingRegions[conf.Id]+ if err := o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: fmt.Sprintf("\nPicked %v region(s) for deployment.\n", strings.Join(regions, ",")),+ },+ },+ }},+ }); err != nil {+ return err+ }++ for _, region := range regions {+ if region != "us-central1" {+ _, err := exec.Exec(ctx, &Execution{+ TaskID: "mirror-" + region,+ AgentID: "docker-mirror",+ Inputs: []*proto.Content{+ {+ Role: "user",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "Provide a mirror to the region if the image doesn't exist.",+ },+ },+ },+ },+ })+ if err != nil {+ return err+ }+ }+ if err := o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "* Deploying to " + region + ", this may take a while...\n",+ },+ },+ }},+ }); err != nil {+ return err+ }+ if err := o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "* kubectl apply -f deployment.yaml\n",+ },+ },+ }},+ }); err != nil {+ return err+ }++ time.Sleep(1500 * time.Millisecond)+ if err := o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: fmt.Sprintf("* Deployment complete. You can access the service at https://%v.test.services.acme.com\n\n", region),+ },+ },+ }},+ }); err != nil {+ return err+ }+ delete(pendingRegions, conf.Id)+ }+ return nil+ }++ var regions []string = []string{"europe-north1", "asia-east1", "us-west2"}+ {+ inputs := t.Inputs+ inputs = append(inputs, &proto.Content{+ Role: "user",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "Return comma separated regions, no other text. If instructed to use a region already, just return it. Otherwise, return europe-north1,asia-east1,us-west2",+ },+ },+ })+ var outputs []*proto.Content+ if err := e.Exec(ctx, &agent.Task{+ ID: "region-picker",+ AgentID: "gemini",+ Inputs: inputs,+ }, func(resp *proto.ProcessResponse) error {+ outputs = append(outputs, resp.Contents...)+ return nil+ }); err != nil {+ return err+ }++ last := outputs[len(outputs)-1]+ text := last.GetContent().(*proto.Content_Text).Text.GetText()+ regions = strings.Split(text, ",")+ }++ confID := uuid.NewString()+ pendingRegions[confID] = regions+ return o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Confirmation{+ Confirmation: &proto.ConfirmationContent{+ Id: confID,+ Question: fmt.Sprintf("Picked %v region(s) to deploy, continue?", strings.Join(regions, ",")),+ },+ },+ }},+ })+}++func (a *KubernetesDeployAgent) HealthCheck(ctx context.Context) error {+ return nil+}++// Close gracefully shuts down the agent.+func (a *KubernetesDeployAgent) Close() error {+ return nil+}++type Executor struct {+ exec agent.TaskExecutor+ handler agent.OutputHandler+ history []*proto.Content+}++func NewExecutor(e agent.TaskExecutor, o agent.OutputHandler) *Executor {+ return &Executor{+ exec: e,+ handler: o,+ }+}++type Execution struct {+ TaskID string+ AgentID string+ Inputs []*proto.Content+}++func (e *Executor) Exec(ctx context.Context, execution *Execution) ([]*proto.Content, error) {+ var outputs []*proto.Content+ if execution.TaskID == "" {+ var err error+ execution.TaskID, err = randomHex(8)+ if err != nil {+ return nil, err+ }+ }++ if err := e.exec.Exec(ctx, &agent.Task{+ ID: execution.TaskID,+ AgentID: execution.AgentID,+ Inputs: execution.Inputs,+ }, func(resp *proto.ProcessResponse) error {+ outputs = append(outputs, resp.Contents...)+ return e.handler(resp)+ }); err != nil {+ return nil, err+ }+ return outputs, nil+}++func (e *Executor) Append(c ...*proto.Content) {+ e.history = append(e.history, c...)+}++func (e *Executor) History() []*proto.Content {+ return e.history+}++func randomHex(n int) (string, error) {+ bytes := make([]byte, n/2)+ if _, err := rand.Read(bytes); err != nil {+ return "", err+ }+ return hex.EncodeToString(bytes), nil+}diff --git a/internal/testagent/docker.go b/internal/testagent/docker.gonew file mode 100644index 0000000..668f7c4--- /dev/null+++ b/internal/testagent/docker.go@@ -0,0 +1,95 @@+package testagent++import (+ "context"+ "time"++ "github.com/google/gar/agent"+ "github.com/google/gar/proto"+)++type DockerBuilderAgent struct{}++func (a *DockerBuilderAgent) Process(ctx context.Context, t *agent.Task, e agent.TaskExecutor, o agent.OutputHandler) error {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "\n\nBuilding the docker image now...\n",+ },+ },+ }},+ })++ time.Sleep(500 * time.Millisecond)+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "* us-central1-docker.pkg.dev/acme/test/test:latest is built and is ready to push.\n",+ },+ },+ }},+ })++ time.Sleep(1000 * time.Millisecond)+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "* The container image is pushed.\n\n",+ },+ },+ }},+ })+ return nil+}++func (a *DockerBuilderAgent) HealthCheck(ctx context.Context) error {+ return nil+}++// Close gracefully shuts down the agent.+func (a *DockerBuilderAgent) Close() error {+ return nil+}++type DockerMirrorAgent struct{}++func (a *DockerMirrorAgent) Process(ctx context.Context, t *agent.Task, e agent.TaskExecutor, o agent.OutputHandler) error {+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "* Starting pushing docker image now...\n",+ },+ },+ }},+ })++ time.Sleep(2000 * time.Millisecond)+ o(&proto.ProcessResponse{+ Contents: []*proto.Content{{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{+ Text: "* The container image is mirrored.\n",+ },+ },+ }},+ })+ return nil+}++func (a *DockerMirrorAgent) HealthCheck(ctx context.Context) error {+ return nil+}++// Close gracefully shuts down the agent.+func (a *DockerMirrorAgent) Close() error {+ return nil+}diff --git a/proto/gar.pb.go b/proto/gar.pb.goindex 33f432b..55ce790 100644--- a/proto/gar.pb.go+++ b/proto/gar.pb.go@@ -14,8 +14,8 @@// Code generated by protoc-gen-go. DO NOT EDIT.// versions:-// protoc-gen-go v1.35.1-// protoc v5.28.2+// protoc-gen-go v1.36.11+// protoc v3.21.9// source: proto/gar.protopackage proto@@ -27,6 +27,7 @@ import (timestamppb "google.golang.org/protobuf/types/known/timestamppb"reflect "reflect"sync "sync"+ unsafe "unsafe")const (@@ -41,22 +42,22 @@ type State int32const (State_STATE_UNSPECIFIED State = 0 // Unspecified state- State_STATE_RUNNING State = 1 // Session is currently running- State_STATE_FAILED State = 2 // Session failed- State_STATE_COMPLETED State = 3 // Completed, can accept new triggers+ State_STATE_PENDING State = 1+ State_STATE_FAILED State = 2+ State_STATE_COMPLETED State = 3)// Enum value maps for State.var (State_name = map[int32]string{0: "STATE_UNSPECIFIED",- 1: "STATE_RUNNING",+ 1: "STATE_PENDING",2: "STATE_FAILED",3: "STATE_COMPLETED",}State_value = map[string]int32{"STATE_UNSPECIFIED": 0,- "STATE_RUNNING": 1,+ "STATE_PENDING": 1,"STATE_FAILED": 2,"STATE_COMPLETED": 3,}@@ -91,15 +92,10 @@ func (State) EnumDescriptor() ([]byte, []int) {// ProcessRequest is an input to an agent.type ProcessRequest struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ Contents []*Content `protobuf:"bytes,1,rep,name=contents,proto3" json:"contents,omitempty"`unknownFields protoimpl.UnknownFields-- // Checkpoint is the optional checkpoint associated with- // the contents.- CheckpointId string `protobuf:"bytes,1,opt,name=checkpoint_id,json=checkpointId,proto3" json:"checkpoint_id,omitempty"`- // Contents as input.- Contents []*Content `protobuf:"bytes,2,rep,name=contents,proto3" json:"contents,omitempty"`+ sizeCache protoimpl.SizeCache}func (x *ProcessRequest) Reset() {@@ -132,13 +128,6 @@ func (*ProcessRequest) Descriptor() ([]byte, []int) {return file_proto_gar_proto_rawDescGZIP(), []int{0}}-func (x *ProcessRequest) GetCheckpointId() string {- if x != nil {- return x.CheckpointId- }- return ""-}-func (x *ProcessRequest) GetContents() []*Content {if x != nil {return x.Contents@@ -149,18 +138,12 @@ func (x *ProcessRequest) GetContents() []*Content {// ProcessResponse is an output from an agent.// It can be returned in a streaming fashion.type ProcessResponse struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ CheckpointId string `protobuf:"bytes,1,opt,name=checkpoint_id,json=checkpointId,proto3" json:"checkpoint_id,omitempty"`+ Contents []*Content `protobuf:"bytes,2,rep,name=contents,proto3" json:"contents,omitempty"`+ FromCache bool `protobuf:"varint,3,opt,name=from_cache,json=fromCache,proto3" json:"from_cache,omitempty"`unknownFields protoimpl.UnknownFields-- // Checkpoint is the optional checkpoint associated with- // the contents.- CheckpointId string `protobuf:"bytes,1,opt,name=checkpoint_id,json=checkpointId,proto3" json:"checkpoint_id,omitempty"`- // Contents as output.- Contents []*Content `protobuf:"bytes,2,rep,name=contents,proto3" json:"contents,omitempty"`- // Optional agent handoff. If set controller, hands off the- // execution to the provided agent.- AgentHandoff string `protobuf:"bytes,3,opt,name=agent_handoff,json=agentHandoff,proto3" json:"agent_handoff,omitempty"`+ sizeCache protoimpl.SizeCache}func (x *ProcessResponse) Reset() {@@ -207,20 +190,19 @@ func (x *ProcessResponse) GetContents() []*Content {return nil}-func (x *ProcessResponse) GetAgentHandoff() string {+func (x *ProcessResponse) GetFromCache() bool {if x != nil {- return x.AgentHandoff+ return x.FromCache}- return ""+ return false}// TextContent represents a text content.type TextContent struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ Text string `protobuf:"bytes,3,opt,name=text,proto3" json:"text,omitempty"`unknownFields protoimpl.UnknownFields-- Text string `protobuf:"bytes,3,opt,name=text,proto3" json:"text,omitempty"`+ sizeCache protoimpl.SizeCache}func (x *TextContent) Reset() {@@ -261,11 +243,10 @@ func (x *TextContent) GetText() string {}type ApprovalDecision struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ Approved bool `protobuf:"varint,1,opt,name=approved,proto3" json:"approved,omitempty"`unknownFields protoimpl.UnknownFields-- Approved bool `protobuf:"varint,1,opt,name=approved,proto3" json:"approved,omitempty"`+ sizeCache protoimpl.SizeCache}func (x *ApprovalDecision) Reset() {@@ -306,11 +287,10 @@ func (x *ApprovalDecision) GetApproved() bool {}type DeclineDecision struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ Declined bool `protobuf:"varint,1,opt,name=declined,proto3" json:"declined,omitempty"`unknownFields protoimpl.UnknownFields-- Declined bool `protobuf:"varint,1,opt,name=declined,proto3" json:"declined,omitempty"`+ sizeCache protoimpl.SizeCache}func (x *DeclineDecision) Reset() {@@ -351,17 +331,16 @@ func (x *DeclineDecision) GetDeclined() bool {}type ConfirmationContent struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`- Question string `protobuf:"bytes,4,opt,name=question,proto3" json:"question,omitempty"`- // Types that are assignable to Decision:+ state protoimpl.MessageState `protogen:"open.v1"`+ Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`+ Question string `protobuf:"bytes,4,opt,name=question,proto3" json:"question,omitempty"`+ // Types that are valid to be assigned to Decision://// *ConfirmationContent_Approval// *ConfirmationContent_Decline- Decision isConfirmationContent_Decision `protobuf_oneof:"decision"`+ Decision isConfirmationContent_Decision `protobuf_oneof:"decision"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *ConfirmationContent) Reset() {@@ -408,23 +387,27 @@ func (x *ConfirmationContent) GetQuestion() string {return ""}-func (m *ConfirmationContent) GetDecision() isConfirmationContent_Decision {- if m != nil {- return m.Decision+func (x *ConfirmationContent) GetDecision() isConfirmationContent_Decision {+ if x != nil {+ return x.Decision}return nil}func (x *ConfirmationContent) GetApproval() *ApprovalDecision {- if x, ok := x.GetDecision().(*ConfirmationContent_Approval); ok {- return x.Approval+ if x != nil {+ if x, ok := x.Decision.(*ConfirmationContent_Approval); ok {+ return x.Approval+ }}return nil}func (x *ConfirmationContent) GetDecline() *DeclineDecision {- if x, ok := x.GetDecision().(*ConfirmationContent_Decline); ok {- return x.Decline+ if x != nil {+ if x, ok := x.Decision.(*ConfirmationContent_Decline); ok {+ return x.Decline+ }}return nil}@@ -446,14 +429,13 @@ func (*ConfirmationContent_Approval) isConfirmationContent_Decision() {}func (*ConfirmationContent_Decline) isConfirmationContent_Decision() {}type FunctionCallContent struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- Args *structpb.Struct `protobuf:"bytes,2,opt,name=args,proto3" json:"args,omitempty"`- Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`- ThoughtSignature []byte `protobuf:"bytes,4,opt,name=thought_signature,json=thoughtSignature,proto3" json:"thought_signature,omitempty"`+ state protoimpl.MessageState `protogen:"open.v1"`+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+ Args *structpb.Struct `protobuf:"bytes,2,opt,name=args,proto3" json:"args,omitempty"`+ Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`+ ThoughtSignature []byte `protobuf:"bytes,4,opt,name=thought_signature,json=thoughtSignature,proto3" json:"thought_signature,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *FunctionCallContent) Reset() {@@ -515,13 +497,12 @@ func (x *FunctionCallContent) GetThoughtSignature() []byte {}type FunctionResponseContent struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+ Response *structpb.Struct `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"`+ Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`unknownFields protoimpl.UnknownFields-- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- Response *structpb.Struct `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"`- Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`+ sizeCache protoimpl.SizeCache}func (x *FunctionResponseContent) Reset() {@@ -577,18 +558,17 @@ func (x *FunctionResponseContent) GetId() string {// Content represents a message with role, type, mimetype, and data fieldstype Content struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- // Types that are assignable to Content:+ state protoimpl.MessageState `protogen:"open.v1"`+ // Types that are valid to be assigned to Content://// *Content_Text// *Content_Confirmation// *Content_FunctionCall// *Content_FunctionResponse- Content isContent_Content `protobuf_oneof:"content"`- Role string `protobuf:"bytes,1000,opt,name=role,proto3" json:"role,omitempty"` // The role of the content (e.g., "user", "assistant", "system")+ Content isContent_Content `protobuf_oneof:"content"`+ Role string `protobuf:"bytes,1000,opt,name=role,proto3" json:"role,omitempty"` // The role of the content (e.g., "user", "assistant", "system")+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *Content) Reset() {@@ -621,37 +601,45 @@ func (*Content) Descriptor() ([]byte, []int) {return file_proto_gar_proto_rawDescGZIP(), []int{8}}-func (m *Content) GetContent() isContent_Content {- if m != nil {- return m.Content+func (x *Content) GetContent() isContent_Content {+ if x != nil {+ return x.Content}return nil}func (x *Content) GetText() *TextContent {- if x, ok := x.GetContent().(*Content_Text); ok {- return x.Text+ if x != nil {+ if x, ok := x.Content.(*Content_Text); ok {+ return x.Text+ }}return nil}func (x *Content) GetConfirmation() *ConfirmationContent {- if x, ok := x.GetContent().(*Content_Confirmation); ok {- return x.Confirmation+ if x != nil {+ if x, ok := x.Content.(*Content_Confirmation); ok {+ return x.Confirmation+ }}return nil}func (x *Content) GetFunctionCall() *FunctionCallContent {- if x, ok := x.GetContent().(*Content_FunctionCall); ok {- return x.FunctionCall+ if x != nil {+ if x, ok := x.Content.(*Content_FunctionCall); ok {+ return x.FunctionCall+ }}return nil}func (x *Content) GetFunctionResponse() *FunctionResponseContent {- if x, ok := x.GetContent().(*Content_FunctionResponse); ok {- return x.FunctionResponse+ if x != nil {+ if x, ok := x.Content.(*Content_FunctionResponse); ok {+ return x.FunctionResponse+ }}return nil}@@ -691,32 +679,35 @@ func (*Content_FunctionCall) isContent_Content() {}func (*Content_FunctionResponse) isContent_Content() {}-// Event that represents a session state change.-// Some sessions may not be resumable based on their latest state.-// For example, controller doesn't continue a session once-// the state is set to STATE_FAILED.-type SessionStateEvent struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+// ExecutionEvent is the entry in the event log. ExecutionEvents are used+// to record the actions taken place in the executor.+// The executor can replay the events for resumability.+type ExecutionEvent struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ TaskId string `protobuf:"bytes,2,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"`+ AgentId string `protobuf:"bytes,3,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"`+ Inputs []*Content `protobuf:"bytes,4,rep,name=inputs,proto3" json:"inputs,omitempty"`+ Outputs []*Content `protobuf:"bytes,5,rep,name=outputs,proto3" json:"outputs,omitempty"`+ State State `protobuf:"varint,6,opt,name=state,proto3,enum=proto.State" json:"state,omitempty"`+ Timestamp *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // string checkpoint_id = 10;unknownFields protoimpl.UnknownFields-- State State `protobuf:"varint,1,opt,name=state,proto3,enum=proto.State" json:"state,omitempty"`+ sizeCache protoimpl.SizeCache}-func (x *SessionStateEvent) Reset() {- *x = SessionStateEvent{}+func (x *ExecutionEvent) Reset() {+ *x = ExecutionEvent{}mi := &file_proto_gar_proto_msgTypes[9]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}-func (x *SessionStateEvent) String() string {+func (x *ExecutionEvent) String() string {return protoimpl.X.MessageStringOf(x)}-func (*SessionStateEvent) ProtoMessage() {}+func (*ExecutionEvent) ProtoMessage() {}-func (x *SessionStateEvent) ProtoReflect() protoreflect.Message {+func (x *ExecutionEvent) ProtoReflect() protoreflect.Message {mi := &file_proto_gar_proto_msgTypes[9]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))@@ -728,298 +719,63 @@ func (x *SessionStateEvent) ProtoReflect() protoreflect.Message {return mi.MessageOf(x)}-// Deprecated: Use SessionStateEvent.ProtoReflect.Descriptor instead.-func (*SessionStateEvent) Descriptor() ([]byte, []int) {+// Deprecated: Use ExecutionEvent.ProtoReflect.Descriptor instead.+func (*ExecutionEvent) Descriptor() ([]byte, []int) {return file_proto_gar_proto_rawDescGZIP(), []int{9}}-func (x *SessionStateEvent) GetState() State {- if x != nil {- return x.State- }- return State_STATE_UNSPECIFIED-}--// AgentCallEvent represents an agent call.-type AgentCallEvent struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- Sender string `protobuf:"bytes,3,opt,name=sender,proto3" json:"sender,omitempty"`- Contents []*Content `protobuf:"bytes,4,rep,name=contents,proto3" json:"contents,omitempty"`- AwaitingMore bool `protobuf:"varint,5,opt,name=awaiting_more,json=awaitingMore,proto3" json:"awaiting_more,omitempty"`-}--func (x *AgentCallEvent) Reset() {- *x = AgentCallEvent{}- mi := &file_proto_gar_proto_msgTypes[10]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *AgentCallEvent) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*AgentCallEvent) ProtoMessage() {}--func (x *AgentCallEvent) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[10]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use AgentCallEvent.ProtoReflect.Descriptor instead.-func (*AgentCallEvent) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{10}-}--func (x *AgentCallEvent) GetSender() string {+func (x *ExecutionEvent) GetTaskId() string {if x != nil {- return x.Sender+ return x.TaskId}return ""}-func (x *AgentCallEvent) GetContents() []*Content {+func (x *ExecutionEvent) GetAgentId() string {if x != nil {- return x.Contents- }- return nil-}--func (x *AgentCallEvent) GetAwaitingMore() bool {- if x != nil {- return x.AwaitingMore- }- return false-}--// HandoffEvent represents an agent handoff.-// Controller records the agent handoff with-// associated content.-type HandoffEvent struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- SourceAgentId string `protobuf:"bytes,3,opt,name=source_agent_id,json=sourceAgentId,proto3" json:"source_agent_id,omitempty"`- TargetAgentId string `protobuf:"bytes,4,opt,name=target_agent_id,json=targetAgentId,proto3" json:"target_agent_id,omitempty"`- Contents []*Content `protobuf:"bytes,5,rep,name=contents,proto3" json:"contents,omitempty"`-}--func (x *HandoffEvent) Reset() {- *x = HandoffEvent{}- mi := &file_proto_gar_proto_msgTypes[11]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *HandoffEvent) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*HandoffEvent) ProtoMessage() {}--func (x *HandoffEvent) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[11]- if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use HandoffEvent.ProtoReflect.Descriptor instead.-func (*HandoffEvent) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{11}-}--func (x *HandoffEvent) GetSourceAgentId() string {- if x != nil {- return x.SourceAgentId- }- return ""-}--func (x *HandoffEvent) GetTargetAgentId() string {- if x != nil {- return x.TargetAgentId+ return x.AgentId}return ""}-func (x *HandoffEvent) GetContents() []*Content {+func (x *ExecutionEvent) GetInputs() []*Content {if x != nil {- return x.Contents+ return x.Inputs}return nil}-// Event is the entry in the event log. Events are used-// to record the actions taken place in the GAR controller.-// GAR controller can replay the events for resumability.-type Event struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`- CheckpointId string `protobuf:"bytes,2,opt,name=checkpoint_id,json=checkpointId,proto3" json:"checkpoint_id,omitempty"`- SenderName string `protobuf:"bytes,3,opt,name=sender_name,json=senderName,proto3" json:"sender_name,omitempty"`- SenderId string `protobuf:"bytes,4,opt,name=sender_id,json=senderId,proto3" json:"sender_id,omitempty"`- Timestamp *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"`- ControllerTimestamp *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=controller_timestamp,json=controllerTimestamp,proto3" json:"controller_timestamp,omitempty"`- // Types that are assignable to Kind:- //- // *Event_SessionStateEvent- // *Event_AgentCallEvent- // *Event_HandoffEvent- Kind isEvent_Kind `protobuf_oneof:"kind"`-}--func (x *Event) Reset() {- *x = Event{}- mi := &file_proto_gar_proto_msgTypes[12]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)-}--func (x *Event) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*Event) ProtoMessage() {}--func (x *Event) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[12]+func (x *ExecutionEvent) GetOutputs() []*Content {if x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use Event.ProtoReflect.Descriptor instead.-func (*Event) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{12}-}--func (x *Event) GetSessionId() string {- if x != nil {- return x.SessionId- }- return ""-}--func (x *Event) GetCheckpointId() string {- if x != nil {- return x.CheckpointId- }- return ""-}--func (x *Event) GetSenderName() string {- if x != nil {- return x.SenderName+ return x.Outputs}- return ""+ return nil}-func (x *Event) GetSenderId() string {+func (x *ExecutionEvent) GetState() State {if x != nil {- return x.SenderId+ return x.State}- return ""+ return State_STATE_UNSPECIFIED}-func (x *Event) GetTimestamp() *timestamppb.Timestamp {+func (x *ExecutionEvent) GetTimestamp() *timestamppb.Timestamp {if x != nil {return x.Timestamp}return nil}-func (x *Event) GetControllerTimestamp() *timestamppb.Timestamp {- if x != nil {- return x.ControllerTimestamp- }- return nil-}--func (m *Event) GetKind() isEvent_Kind {- if m != nil {- return m.Kind- }- return nil-}--func (x *Event) GetSessionStateEvent() *SessionStateEvent {- if x, ok := x.GetKind().(*Event_SessionStateEvent); ok {- return x.SessionStateEvent- }- return nil-}--func (x *Event) GetAgentCallEvent() *AgentCallEvent {- if x, ok := x.GetKind().(*Event_AgentCallEvent); ok {- return x.AgentCallEvent- }- return nil-}--func (x *Event) GetHandoffEvent() *HandoffEvent {- if x, ok := x.GetKind().(*Event_HandoffEvent); ok {- return x.HandoffEvent- }- return nil-}--type isEvent_Kind interface {- isEvent_Kind()-}--type Event_SessionStateEvent struct {- SessionStateEvent *SessionStateEvent `protobuf:"bytes,7,opt,name=session_state_event,json=sessionStateEvent,proto3,oneof"` // TODO: remove-}--type Event_AgentCallEvent struct {- AgentCallEvent *AgentCallEvent `protobuf:"bytes,8,opt,name=agent_call_event,json=agentCallEvent,proto3,oneof"`-}--type Event_HandoffEvent struct {- HandoffEvent *HandoffEvent `protobuf:"bytes,9,opt,name=handoff_event,json=handoffEvent,proto3,oneof"`-}--func (*Event_SessionStateEvent) isEvent_Kind() {}--func (*Event_AgentCallEvent) isEvent_Kind() {}--func (*Event_HandoffEvent) isEvent_Kind() {}-// HealthCheckRequest for agent health checkstype HealthCheckRequest struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *HealthCheckRequest) Reset() {*x = HealthCheckRequest{}- mi := &file_proto_gar_proto_msgTypes[13]+ mi := &file_proto_gar_proto_msgTypes[10]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1031,7 +787,7 @@ func (x *HealthCheckRequest) String() string {func (*HealthCheckRequest) ProtoMessage() {}func (x *HealthCheckRequest) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[13]+ mi := &file_proto_gar_proto_msgTypes[10]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1044,22 +800,21 @@ func (x *HealthCheckRequest) ProtoReflect() protoreflect.Message {// Deprecated: Use HealthCheckRequest.ProtoReflect.Descriptor instead.func (*HealthCheckRequest) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{13}+ return file_proto_gar_proto_rawDescGZIP(), []int{10}}// HealthCheckResponse contains agent health statustype HealthCheckResponse struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ Healthy bool `protobuf:"varint,1,opt,name=healthy,proto3" json:"healthy,omitempty"`+ Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`unknownFields protoimpl.UnknownFields-- Healthy bool `protobuf:"varint,1,opt,name=healthy,proto3" json:"healthy,omitempty"`- Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`+ sizeCache protoimpl.SizeCache}func (x *HealthCheckResponse) Reset() {*x = HealthCheckResponse{}- mi := &file_proto_gar_proto_msgTypes[14]+ mi := &file_proto_gar_proto_msgTypes[11]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1071,7 +826,7 @@ func (x *HealthCheckResponse) String() string {func (*HealthCheckResponse) ProtoMessage() {}func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[14]+ mi := &file_proto_gar_proto_msgTypes[11]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1084,7 +839,7 @@ func (x *HealthCheckResponse) ProtoReflect() protoreflect.Message {// Deprecated: Use HealthCheckResponse.ProtoReflect.Descriptor instead.func (*HealthCheckResponse) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{14}+ return file_proto_gar_proto_rawDescGZIP(), []int{11}}func (x *HealthCheckResponse) GetHealthy() bool {@@ -1103,17 +858,17 @@ func (x *HealthCheckResponse) GetMessage() string {// TriggerSessionRequest for triggering a new sessiontype TriggerSessionRequest struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // Unique session identifier+ AgentId string `protobuf:"bytes,2,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` // Agent ID, if empty planner is used.+ Inputs []*Content `protobuf:"bytes,3,rep,name=inputs,proto3" json:"inputs,omitempty"` // Input content to processunknownFields protoimpl.UnknownFields-- SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // Unique session identifier- Inputs []*Content `protobuf:"bytes,2,rep,name=inputs,proto3" json:"inputs,omitempty"` // Input content to process+ sizeCache protoimpl.SizeCache}func (x *TriggerSessionRequest) Reset() {*x = TriggerSessionRequest{}- mi := &file_proto_gar_proto_msgTypes[15]+ mi := &file_proto_gar_proto_msgTypes[12]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1125,7 +880,7 @@ func (x *TriggerSessionRequest) String() string {func (*TriggerSessionRequest) ProtoMessage() {}func (x *TriggerSessionRequest) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[15]+ mi := &file_proto_gar_proto_msgTypes[12]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1138,7 +893,7 @@ func (x *TriggerSessionRequest) ProtoReflect() protoreflect.Message {// Deprecated: Use TriggerSessionRequest.ProtoReflect.Descriptor instead.func (*TriggerSessionRequest) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{15}+ return file_proto_gar_proto_rawDescGZIP(), []int{12}}func (x *TriggerSessionRequest) GetSessionId() string {@@ -1148,6 +903,13 @@ func (x *TriggerSessionRequest) GetSessionId() string {return ""}+func (x *TriggerSessionRequest) GetAgentId() string {+ if x != nil {+ return x.AgentId+ }+ return ""+}+func (x *TriggerSessionRequest) GetInputs() []*Content {if x != nil {return x.Inputs@@ -1157,19 +919,17 @@ func (x *TriggerSessionRequest) GetInputs() []*Content {// TriggerSessionResponse contains the result of triggering a sessiontype TriggerSessionResponse struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // Session ID (in case it was generated or modified by server)+ Outputs []*Content `protobuf:"bytes,2,rep,name=outputs,proto3" json:"outputs,omitempty"` // Output content+ State State `protobuf:"varint,3,opt,name=state,proto3,enum=proto.State" json:"state,omitempty"` // Session stateunknownFields protoimpl.UnknownFields-- SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` // Session ID (in case it was generated or modified by server)- CheckpointId string `protobuf:"bytes,2,opt,name=checkpoint_id,json=checkpointId,proto3" json:"checkpoint_id,omitempty"` // Current checkpoint ID- Outputs []*Content `protobuf:"bytes,3,rep,name=outputs,proto3" json:"outputs,omitempty"` // Output content- State State `protobuf:"varint,4,opt,name=state,proto3,enum=proto.State" json:"state,omitempty"` // Session state+ sizeCache protoimpl.SizeCache}func (x *TriggerSessionResponse) Reset() {*x = TriggerSessionResponse{}- mi := &file_proto_gar_proto_msgTypes[16]+ mi := &file_proto_gar_proto_msgTypes[13]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1181,7 +941,7 @@ func (x *TriggerSessionResponse) String() string {func (*TriggerSessionResponse) ProtoMessage() {}func (x *TriggerSessionResponse) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[16]+ mi := &file_proto_gar_proto_msgTypes[13]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1194,7 +954,7 @@ func (x *TriggerSessionResponse) ProtoReflect() protoreflect.Message {// Deprecated: Use TriggerSessionResponse.ProtoReflect.Descriptor instead.func (*TriggerSessionResponse) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{16}+ return file_proto_gar_proto_rawDescGZIP(), []int{13}}func (x *TriggerSessionResponse) GetSessionId() string {@@ -1204,13 +964,6 @@ func (x *TriggerSessionResponse) GetSessionId() string {return ""}-func (x *TriggerSessionResponse) GetCheckpointId() string {- if x != nil {- return x.CheckpointId- }- return ""-}-func (x *TriggerSessionResponse) GetOutputs() []*Content {if x != nil {return x.Outputs@@ -1226,18 +979,17 @@ func (x *TriggerSessionResponse) GetState() State {}type ForkSessionRequest struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- SrcSessionId string `protobuf:"bytes,1,opt,name=src_session_id,json=srcSessionId,proto3" json:"src_session_id,omitempty"`- SrcCheckpointId string `protobuf:"bytes,2,opt,name=src_checkpoint_id,json=srcCheckpointId,proto3" json:"src_checkpoint_id,omitempty"` // Checkpoint ID within the source session to fork from.- DestSessionId string `protobuf:"bytes,3,opt,name=dest_session_id,json=destSessionId,proto3" json:"dest_session_id,omitempty"` // New session ID. If provided, must not exist.+ state protoimpl.MessageState `protogen:"open.v1"`+ SrcSessionId string `protobuf:"bytes,1,opt,name=src_session_id,json=srcSessionId,proto3" json:"src_session_id,omitempty"`+ SrcCheckpointId string `protobuf:"bytes,2,opt,name=src_checkpoint_id,json=srcCheckpointId,proto3" json:"src_checkpoint_id,omitempty"` // Checkpoint ID within the source session to fork from.+ DestSessionId string `protobuf:"bytes,3,opt,name=dest_session_id,json=destSessionId,proto3" json:"dest_session_id,omitempty"` // New session ID. If provided, must not exist.+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *ForkSessionRequest) Reset() {*x = ForkSessionRequest{}- mi := &file_proto_gar_proto_msgTypes[17]+ mi := &file_proto_gar_proto_msgTypes[14]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1249,7 +1001,7 @@ func (x *ForkSessionRequest) String() string {func (*ForkSessionRequest) ProtoMessage() {}func (x *ForkSessionRequest) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[17]+ mi := &file_proto_gar_proto_msgTypes[14]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1262,7 +1014,7 @@ func (x *ForkSessionRequest) ProtoReflect() protoreflect.Message {// Deprecated: Use ForkSessionRequest.ProtoReflect.Descriptor instead.func (*ForkSessionRequest) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{17}+ return file_proto_gar_proto_rawDescGZIP(), []int{14}}func (x *ForkSessionRequest) GetSrcSessionId() string {@@ -1287,16 +1039,15 @@ func (x *ForkSessionRequest) GetDestSessionId() string {}type ForkSessionResponse struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ NewSessionId string `protobuf:"bytes,1,opt,name=new_session_id,json=newSessionId,proto3" json:"new_session_id,omitempty"` // New session ID (in case it was generated or modified by server)unknownFields protoimpl.UnknownFields-- NewSessionId string `protobuf:"bytes,1,opt,name=new_session_id,json=newSessionId,proto3" json:"new_session_id,omitempty"` // New session ID (in case it was generated or modified by server)+ sizeCache protoimpl.SizeCache}func (x *ForkSessionResponse) Reset() {*x = ForkSessionResponse{}- mi := &file_proto_gar_proto_msgTypes[18]+ mi := &file_proto_gar_proto_msgTypes[15]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1308,7 +1059,7 @@ func (x *ForkSessionResponse) String() string {func (*ForkSessionResponse) ProtoMessage() {}func (x *ForkSessionResponse) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[18]+ mi := &file_proto_gar_proto_msgTypes[15]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1321,7 +1072,7 @@ func (x *ForkSessionResponse) ProtoReflect() protoreflect.Message {// Deprecated: Use ForkSessionResponse.ProtoReflect.Descriptor instead.func (*ForkSessionResponse) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{18}+ return file_proto_gar_proto_rawDescGZIP(), []int{15}}func (x *ForkSessionResponse) GetNewSessionId() string {@@ -1332,16 +1083,15 @@ func (x *ForkSessionResponse) GetNewSessionId() string {}type RemoteAgentConfig struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // gRPC address for remote agentsunknownFields protoimpl.UnknownFields-- Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // gRPC address for remote agents+ sizeCache protoimpl.SizeCache}func (x *RemoteAgentConfig) Reset() {*x = RemoteAgentConfig{}- mi := &file_proto_gar_proto_msgTypes[19]+ mi := &file_proto_gar_proto_msgTypes[16]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1353,7 +1103,7 @@ func (x *RemoteAgentConfig) String() string {func (*RemoteAgentConfig) ProtoMessage() {}func (x *RemoteAgentConfig) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[19]+ mi := &file_proto_gar_proto_msgTypes[16]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1366,7 +1116,7 @@ func (x *RemoteAgentConfig) ProtoReflect() protoreflect.Message {// Deprecated: Use RemoteAgentConfig.ProtoReflect.Descriptor instead.func (*RemoteAgentConfig) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{19}+ return file_proto_gar_proto_rawDescGZIP(), []int{16}}func (x *RemoteAgentConfig) GetAddress() string {@@ -1378,23 +1128,22 @@ func (x *RemoteAgentConfig) GetAddress() string {// RegisterAgentRequest for registering an agenttype RegisterAgentRequest struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- AgentId string `protobuf:"bytes,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"`- Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Human-readable name for the agent- Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` // Description of agent capabilities- Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`- // Types that are assignable to Config:+ state protoimpl.MessageState `protogen:"open.v1"`+ AgentId string `protobuf:"bytes,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"`+ Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // Human-readable name for the agent+ Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` // Description of agent capabilities+ Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`+ // Types that are valid to be assigned to Config://// *RegisterAgentRequest_Remote- Config isRegisterAgentRequest_Config `protobuf_oneof:"config"`+ Config isRegisterAgentRequest_Config `protobuf_oneof:"config"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *RegisterAgentRequest) Reset() {*x = RegisterAgentRequest{}- mi := &file_proto_gar_proto_msgTypes[20]+ mi := &file_proto_gar_proto_msgTypes[17]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1406,7 +1155,7 @@ func (x *RegisterAgentRequest) String() string {func (*RegisterAgentRequest) ProtoMessage() {}func (x *RegisterAgentRequest) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[20]+ mi := &file_proto_gar_proto_msgTypes[17]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1419,7 +1168,7 @@ func (x *RegisterAgentRequest) ProtoReflect() protoreflect.Message {// Deprecated: Use RegisterAgentRequest.ProtoReflect.Descriptor instead.func (*RegisterAgentRequest) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{20}+ return file_proto_gar_proto_rawDescGZIP(), []int{17}}func (x *RegisterAgentRequest) GetAgentId() string {@@ -1450,16 +1199,18 @@ func (x *RegisterAgentRequest) GetMetadata() map[string]string {return nil}-func (m *RegisterAgentRequest) GetConfig() isRegisterAgentRequest_Config {- if m != nil {- return m.Config+func (x *RegisterAgentRequest) GetConfig() isRegisterAgentRequest_Config {+ if x != nil {+ return x.Config}return nil}func (x *RegisterAgentRequest) GetRemote() *RemoteAgentConfig {- if x, ok := x.GetConfig().(*RegisterAgentRequest_Remote); ok {- return x.Remote+ if x != nil {+ if x, ok := x.Config.(*RegisterAgentRequest_Remote); ok {+ return x.Remote+ }}return nil}@@ -1476,14 +1227,14 @@ func (*RegisterAgentRequest_Remote) isRegisterAgentRequest_Config() {}// RegisterAgentResponse contains registration resulttype RegisterAgentResponse struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *RegisterAgentResponse) Reset() {*x = RegisterAgentResponse{}- mi := &file_proto_gar_proto_msgTypes[21]+ mi := &file_proto_gar_proto_msgTypes[18]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1495,7 +1246,7 @@ func (x *RegisterAgentResponse) String() string {func (*RegisterAgentResponse) ProtoMessage() {}func (x *RegisterAgentResponse) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[21]+ mi := &file_proto_gar_proto_msgTypes[18]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1508,21 +1259,20 @@ func (x *RegisterAgentResponse) ProtoReflect() protoreflect.Message {// Deprecated: Use RegisterAgentResponse.ProtoReflect.Descriptor instead.func (*RegisterAgentResponse) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{21}+ return file_proto_gar_proto_rawDescGZIP(), []int{18}}// UnregisterAgentRequest for unregistering an agenttype UnregisterAgentRequest struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`+ AgentId string `protobuf:"bytes,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"`unknownFields protoimpl.UnknownFields-- AgentId string `protobuf:"bytes,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"`+ sizeCache protoimpl.SizeCache}func (x *UnregisterAgentRequest) Reset() {*x = UnregisterAgentRequest{}- mi := &file_proto_gar_proto_msgTypes[22]+ mi := &file_proto_gar_proto_msgTypes[19]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1534,7 +1284,7 @@ func (x *UnregisterAgentRequest) String() string {func (*UnregisterAgentRequest) ProtoMessage() {}func (x *UnregisterAgentRequest) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[22]+ mi := &file_proto_gar_proto_msgTypes[19]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1547,7 +1297,7 @@ func (x *UnregisterAgentRequest) ProtoReflect() protoreflect.Message {// Deprecated: Use UnregisterAgentRequest.ProtoReflect.Descriptor instead.func (*UnregisterAgentRequest) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{22}+ return file_proto_gar_proto_rawDescGZIP(), []int{19}}func (x *UnregisterAgentRequest) GetAgentId() string {@@ -1559,14 +1309,14 @@ func (x *UnregisterAgentRequest) GetAgentId() string {// UnregisterAgentResponse contains unregistration resulttype UnregisterAgentResponse struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache+ state protoimpl.MessageState `protogen:"open.v1"`unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *UnregisterAgentResponse) Reset() {*x = UnregisterAgentResponse{}- mi := &file_proto_gar_proto_msgTypes[23]+ mi := &file_proto_gar_proto_msgTypes[20]ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))ms.StoreMessageInfo(mi)}@@ -1578,7 +1328,7 @@ func (x *UnregisterAgentResponse) String() string {func (*UnregisterAgentResponse) ProtoMessage() {}func (x *UnregisterAgentResponse) ProtoReflect() protoreflect.Message {- mi := &file_proto_gar_proto_msgTypes[23]+ mi := &file_proto_gar_proto_msgTypes[20]if x != nil {ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))if ms.LoadMessageInfo() == nil {@@ -1591,262 +1341,124 @@ func (x *UnregisterAgentResponse) ProtoReflect() protoreflect.Message {// Deprecated: Use UnregisterAgentResponse.ProtoReflect.Descriptor instead.func (*UnregisterAgentResponse) Descriptor() ([]byte, []int) {- return file_proto_gar_proto_rawDescGZIP(), []int{23}+ return file_proto_gar_proto_rawDescGZIP(), []int{20}}var File_proto_gar_proto protoreflect.FileDescriptor-var file_proto_gar_proto_rawDesc = []byte{- 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x61, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74,- 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,- 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,- 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c,- 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63,- 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x61, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x63, 0x65,- 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x68, 0x65,- 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,- 0x52, 0x0c, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x2a,- 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b,- 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,- 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x87, 0x01, 0x0a, 0x0f, 0x50,- 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23,- 0x0a, 0x0d, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18,- 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e,- 0x74, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18,- 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f,- 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x12,- 0x23, 0x0a, 0x0d, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x6e, 0x64, 0x6f, 0x66, 0x66,- 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x6e,- 0x64, 0x6f, 0x66, 0x66, 0x22, 0x33, 0x0a, 0x0b, 0x54, 0x65, 0x78, 0x74, 0x43, 0x6f, 0x6e, 0x74,- 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, 0x08,- 0x02, 0x10, 0x03, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x2e, 0x0a, 0x10, 0x41, 0x70, 0x70,- 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a,- 0x08, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,- 0x08, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x64, 0x22, 0x3b, 0x0a, 0x0f, 0x44, 0x65, 0x63,- 0x6c, 0x69, 0x6e, 0x65, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08,- 0x64, 0x65, 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08,- 0x64, 0x65, 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x64, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x52, 0x06,- 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, 0xca, 0x01, 0x0a, 0x13, 0x43, 0x6f, 0x6e, 0x66, 0x69,- 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x0e,- 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a,- 0x0a, 0x08, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,- 0x52, 0x08, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x35, 0x0a, 0x08, 0x61, 0x70,- 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70,- 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x44, 0x65, 0x63,- 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x08, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61,- 0x6c, 0x12, 0x32, 0x0a, 0x07, 0x64, 0x65, 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x06, 0x20, 0x01,- 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x63, 0x6c, 0x69,- 0x6e, 0x65, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x07, 0x64, 0x65,- 0x63, 0x6c, 0x69, 0x6e, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f,- 0x6e, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x52, 0x04, 0x74,- 0x79, 0x70, 0x65, 0x22, 0x93, 0x01, 0x0a, 0x13, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,- 0x43, 0x61, 0x6c, 0x6c, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e,- 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,- 0x2b, 0x0a, 0x04, 0x61, 0x72, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e,- 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,- 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x04, 0x61, 0x72, 0x67, 0x73, 0x12, 0x0e, 0x0a, 0x02,- 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2b, 0x0a, 0x11,- 0x74, 0x68, 0x6f, 0x75, 0x67, 0x68, 0x74, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72,- 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x74, 0x68, 0x6f, 0x75, 0x67, 0x68, 0x74,- 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x72, 0x0a, 0x17, 0x46, 0x75, 0x6e,- 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, 0x6e,- 0x74, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,- 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70,- 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f,- 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72,- 0x75, 0x63, 0x74, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a,- 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xb9, 0x02,- 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x04, 0x74, 0x65, 0x78,- 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,- 0x54, 0x65, 0x78, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x04, 0x74,- 0x65, 0x78, 0x74, 0x12, 0x40, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74,- 0x69, 0x6f, 0x6e, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74,- 0x6f, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f,- 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d,- 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x41, 0x0a, 0x0d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,- 0x6e, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70,- 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61, 0x6c,- 0x6c, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x66, 0x75, 0x6e, 0x63,- 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x4d, 0x0a, 0x11, 0x66, 0x75, 0x6e, 0x63,- 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x1c, 0x20,- 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x75, 0x6e, 0x63,- 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x74,- 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x10, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52,- 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x13, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18,- 0xe8, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x42, 0x09, 0x0a, 0x07,- 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x05, 0x4a, 0x04, 0x08,- 0x06, 0x10, 0x0a, 0x4a, 0x04, 0x08, 0x0b, 0x10, 0x1a, 0x22, 0x37, 0x0a, 0x11, 0x53, 0x65, 0x73,- 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x22,- 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e,- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61,- 0x74, 0x65, 0x22, 0x85, 0x01, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x61, 0x6c, 0x6c,- 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18,- 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x2a, 0x0a,- 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32,- 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52,- 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x77, 0x61,- 0x69, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x6d, 0x6f, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08,- 0x52, 0x0c, 0x61, 0x77, 0x61, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x6f, 0x72, 0x65, 0x4a, 0x04,- 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x22, 0x96, 0x01, 0x0a, 0x0c, 0x48,- 0x61, 0x6e, 0x64, 0x6f, 0x66, 0x66, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x0f, 0x73,- 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03,- 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x41, 0x67, 0x65, 0x6e,- 0x74, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x61, 0x67,- 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x61,- 0x72, 0x67, 0x65, 0x74, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x08, 0x63,- 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e,- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x63,- 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, 0x08,- 0x02, 0x10, 0x03, 0x22, 0xe5, 0x03, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a,- 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d,- 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20,- 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x49,- 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65,- 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x4e, 0x61,- 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18,- 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12,- 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01,- 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,- 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09,- 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x4d, 0x0a, 0x14, 0x63, 0x6f, 0x6e,- 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,- 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74,- 0x61, 0x6d, 0x70, 0x52, 0x13, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x54,- 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x4a, 0x0a, 0x13, 0x73, 0x65, 0x73, 0x73,- 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18,- 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x65,- 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48,- 0x00, 0x52, 0x11, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x45,- 0x76, 0x65, 0x6e, 0x74, 0x12, 0x41, 0x0a, 0x10, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x61,- 0x6c, 0x6c, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15,- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x61, 0x6c, 0x6c,- 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0e, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x61,- 0x6c, 0x6c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x3a, 0x0a, 0x0d, 0x68, 0x61, 0x6e, 0x64, 0x6f,- 0x66, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13,- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x61, 0x6e, 0x64, 0x6f, 0x66, 0x66, 0x45, 0x76,- 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0c, 0x68, 0x61, 0x6e, 0x64, 0x6f, 0x66, 0x66, 0x45, 0x76,- 0x65, 0x6e, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0x14, 0x0a, 0x12, 0x48,- 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,- 0x74, 0x22, 0x49, 0x0a, 0x13, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b,- 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x6c,- 0x74, 0x68, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x68, 0x65, 0x61, 0x6c, 0x74,- 0x68, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20,- 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x5e, 0x0a, 0x15,- 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65,- 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,- 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69,- 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x18, 0x02,- 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6e,- 0x74, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x73, 0x22, 0xaa, 0x01, 0x0a,- 0x16, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52,- 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69,- 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x73,- 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70,- 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63,- 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x07, 0x6f,- 0x75, 0x74, 0x70, 0x75, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70,- 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x6f, 0x75,- 0x74, 0x70, 0x75, 0x74, 0x73, 0x12, 0x22, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x04,- 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61,- 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x8e, 0x01, 0x0a, 0x12, 0x46, 0x6f,- 0x72, 0x6b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,- 0x12, 0x24, 0x0a, 0x0e, 0x73, 0x72, 0x63, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f,- 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x72, 0x63, 0x53, 0x65, 0x73,- 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x73, 0x72, 0x63, 0x5f, 0x63, 0x68,- 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x0f, 0x73, 0x72, 0x63, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x6f, 0x69, 0x6e, 0x74,- 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69,- 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x73,- 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x3b, 0x0a, 0x13, 0x46, 0x6f,- 0x72, 0x6b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,- 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x6e, 0x65, 0x77, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,- 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6e, 0x65, 0x77, 0x53, 0x65,- 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x2d, 0x0a, 0x11, 0x52, 0x65, 0x6d, 0x6f, 0x74,- 0x65, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07,- 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61,- 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0xa9, 0x02, 0x0a, 0x14, 0x52, 0x65, 0x67, 0x69, 0x73,- 0x74, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,- 0x19, 0x0a, 0x08, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,- 0x09, 0x52, 0x07, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,- 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20,- 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20,- 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,- 0x12, 0x45, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x03,- 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73,- 0x74, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e,- 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d,- 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x32, 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x74,- 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,- 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69,- 0x67, 0x48, 0x00, 0x52, 0x06, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d,- 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,- 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14,- 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76,- 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66,- 0x69, 0x67, 0x22, 0x17, 0x0a, 0x15, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x41, 0x67,- 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x33, 0x0a, 0x16, 0x55,- 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x65,- 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x5f, 0x69,- 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x49, 0x64,- 0x22, 0x19, 0x0a, 0x17, 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x41, 0x67,- 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x58, 0x0a, 0x05, 0x53,- 0x74, 0x61, 0x74, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e,- 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x53,- 0x54, 0x41, 0x54, 0x45, 0x5f, 0x52, 0x55, 0x4e, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x10,- 0x0a, 0x0c, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x02,- 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x45,- 0x54, 0x45, 0x44, 0x10, 0x03, 0x32, 0x92, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53,- 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3c, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73,- 0x73, 0x12, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73,- 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,- 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,- 0x28, 0x01, 0x30, 0x01, 0x12, 0x44, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68,- 0x65, 0x63, 0x6b, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x6c,- 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a,- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65,- 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xc1, 0x02, 0x0a, 0x0a, 0x47,- 0x41, 0x52, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4f, 0x0a, 0x0e, 0x54, 0x72, 0x69,- 0x67, 0x67, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x2e, 0x70, 0x72,- 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69,- 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74,- 0x6f, 0x2e, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,- 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x44, 0x0a, 0x0b, 0x46, 0x6f,- 0x72, 0x6b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74,- 0x6f, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71,- 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x6f, 0x72,- 0x6b, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,- 0x12, 0x4a, 0x0a, 0x0d, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e,- 0x74, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74,- 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c,- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x41,- 0x67, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0f,- 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x12,- 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74,- 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e,- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65,- 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x1d,- 0x5a, 0x1b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6f,- 0x67, 0x6c, 0x65, 0x2f, 0x67, 0x61, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70,- 0x72, 0x6f, 0x74, 0x6f, 0x33,-}+const file_proto_gar_proto_rawDesc = "" ++ "\n" ++ "\x0fproto/gar.proto\x12\x05proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/protobuf/struct.proto\"<\n" ++ "\x0eProcessRequest\x12*\n" ++ "\bcontents\x18\x01 \x03(\v2\x0e.proto.ContentR\bcontents\"\x81\x01\n" ++ "\x0fProcessResponse\x12#\n" ++ "\rcheckpoint_id\x18\x01 \x01(\tR\fcheckpointId\x12*\n" ++ "\bcontents\x18\x02 \x03(\v2\x0e.proto.ContentR\bcontents\x12\x1d\n" ++ "\n" ++ "from_cache\x18\x03 \x01(\bR\tfromCache\"3\n" ++ "\vTextContent\x12\x12\n" ++ "\x04text\x18\x03 \x01(\tR\x04textJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03R\x04type\".\n" ++ "\x10ApprovalDecision\x12\x1a\n" ++ "\bapproved\x18\x01 \x01(\bR\bapproved\";\n" ++ "\x0fDeclineDecision\x12\x1a\n" ++ "\bdeclined\x18\x01 \x01(\bR\bdeclinedJ\x04\b\x02\x10\x03R\x06reason\"\xca\x01\n" ++ "\x13ConfirmationContent\x12\x0e\n" ++ "\x02id\x18\x03 \x01(\tR\x02id\x12\x1a\n" ++ "\bquestion\x18\x04 \x01(\tR\bquestion\x125\n" ++ "\bapproval\x18\x05 \x01(\v2\x17.proto.ApprovalDecisionH\x00R\bapproval\x122\n" ++ "\adecline\x18\x06 \x01(\v2\x16.proto.DeclineDecisionH\x00R\adeclineB\n" ++ "\n" ++ "\bdecisionJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03R\x04type\"\x93\x01\n" ++ "\x13FunctionCallContent\x12\x12\n" ++ "\x04name\x18\x01 \x01(\tR\x04name\x12+\n" ++ "\x04args\x18\x02 \x01(\v2\x17.google.protobuf.StructR\x04args\x12\x0e\n" ++ "\x02id\x18\x03 \x01(\tR\x02id\x12+\n" ++ "\x11thought_signature\x18\x04 \x01(\fR\x10thoughtSignature\"r\n" ++ "\x17FunctionResponseContent\x12\x12\n" ++ "\x04name\x18\x01 \x01(\tR\x04name\x123\n" ++ "\bresponse\x18\x02 \x01(\v2\x17.google.protobuf.StructR\bresponse\x12\x0e\n" ++ "\x02id\x18\x03 \x01(\tR\x02id\"\xb9\x02\n" ++ "\aContent\x12(\n" ++ "\x04text\x18\n" ++ " \x01(\v2\x12.proto.TextContentH\x00R\x04text\x12@\n" ++ "\fconfirmation\x18\x1a \x01(\v2\x1a.proto.ConfirmationContentH\x00R\fconfirmation\x12A\n" ++ "\rfunction_call\x18\x1b \x01(\v2\x1a.proto.FunctionCallContentH\x00R\ffunctionCall\x12M\n" ++ "\x11function_response\x18\x1c \x01(\v2\x1e.proto.FunctionResponseContentH\x00R\x10functionResponse\x12\x13\n" ++ "\x04role\x18\xe8\a \x01(\tR\x04roleB\t\n" ++ "\acontentJ\x04\b\x01\x10\x05J\x04\b\x06\x10\n" ++ "J\x04\b\v\x10\x1a\"\xf4\x01\n" ++ "\x0eExecutionEvent\x12\x17\n" ++ "\atask_id\x18\x02 \x01(\tR\x06taskId\x12\x19\n" ++ "\bagent_id\x18\x03 \x01(\tR\aagentId\x12&\n" ++ "\x06inputs\x18\x04 \x03(\v2\x0e.proto.ContentR\x06inputs\x12(\n" ++ "\aoutputs\x18\x05 \x03(\v2\x0e.proto.ContentR\aoutputs\x12\"\n" ++ "\x05state\x18\x06 \x01(\x0e2\f.proto.StateR\x05state\x128\n" ++ "\ttimestamp\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\"\x14\n" ++ "\x12HealthCheckRequest\"I\n" ++ "\x13HealthCheckResponse\x12\x18\n" ++ "\ahealthy\x18\x01 \x01(\bR\ahealthy\x12\x18\n" ++ "\amessage\x18\x02 \x01(\tR\amessage\"y\n" ++ "\x15TriggerSessionRequest\x12\x1d\n" ++ "\n" ++ "session_id\x18\x01 \x01(\tR\tsessionId\x12\x19\n" ++ "\bagent_id\x18\x02 \x01(\tR\aagentId\x12&\n" ++ "\x06inputs\x18\x03 \x03(\v2\x0e.proto.ContentR\x06inputs\"\x85\x01\n" ++ "\x16TriggerSessionResponse\x12\x1d\n" ++ "\n" ++ "session_id\x18\x01 \x01(\tR\tsessionId\x12(\n" ++ "\aoutputs\x18\x02 \x03(\v2\x0e.proto.ContentR\aoutputs\x12\"\n" ++ "\x05state\x18\x03 \x01(\x0e2\f.proto.StateR\x05state\"\x8e\x01\n" ++ "\x12ForkSessionRequest\x12$\n" ++ "\x0esrc_session_id\x18\x01 \x01(\tR\fsrcSessionId\x12*\n" ++ "\x11src_checkpoint_id\x18\x02 \x01(\tR\x0fsrcCheckpointId\x12&\n" ++ "\x0fdest_session_id\x18\x03 \x01(\tR\rdestSessionId\";\n" ++ "\x13ForkSessionResponse\x12$\n" ++ "\x0enew_session_id\x18\x01 \x01(\tR\fnewSessionId\"-\n" ++ "\x11RemoteAgentConfig\x12\x18\n" ++ "\aaddress\x18\x01 \x01(\tR\aaddress\"\xa9\x02\n" ++ "\x14RegisterAgentRequest\x12\x19\n" ++ "\bagent_id\x18\x01 \x01(\tR\aagentId\x12\x12\n" ++ "\x04name\x18\x02 \x01(\tR\x04name\x12 \n" ++ "\vdescription\x18\x03 \x01(\tR\vdescription\x12E\n" ++ "\bmetadata\x18\x04 \x03(\v2).proto.RegisterAgentRequest.MetadataEntryR\bmetadata\x122\n" ++ "\x06remote\x18\x05 \x01(\v2\x18.proto.RemoteAgentConfigH\x00R\x06remote\x1a;\n" ++ "\rMetadataEntry\x12\x10\n" ++ "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" ++ "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01B\b\n" ++ "\x06config\"\x17\n" ++ "\x15RegisterAgentResponse\"3\n" ++ "\x16UnregisterAgentRequest\x12\x19\n" ++ "\bagent_id\x18\x01 \x01(\tR\aagentId\"\x19\n" ++ "\x17UnregisterAgentResponse*X\n" ++ "\x05State\x12\x15\n" ++ "\x11STATE_UNSPECIFIED\x10\x00\x12\x11\n" ++ "\rSTATE_PENDING\x10\x01\x12\x10\n" ++ "\fSTATE_FAILED\x10\x02\x12\x13\n" ++ "\x0fSTATE_COMPLETED\x10\x032\x92\x01\n" ++ "\fAgentService\x12<\n" ++ "\aProcess\x12\x15.proto.ProcessRequest\x1a\x16.proto.ProcessResponse(\x010\x01\x12D\n" ++ "\vHealthCheck\x12\x19.proto.HealthCheckRequest\x1a\x1a.proto.HealthCheckResponse2\xc1\x02\n" ++ "\n" ++ "GARService\x12O\n" ++ "\x0eTriggerSession\x12\x1c.proto.TriggerSessionRequest\x1a\x1d.proto.TriggerSessionResponse0\x01\x12D\n" ++ "\vForkSession\x12\x19.proto.ForkSessionRequest\x1a\x1a.proto.ForkSessionResponse\x12J\n" ++ "\rRegisterAgent\x12\x1b.proto.RegisterAgentRequest\x1a\x1c.proto.RegisterAgentResponse\x12P\n" ++ "\x0fUnregisterAgent\x12\x1d.proto.UnregisterAgentRequest\x1a\x1e.proto.UnregisterAgentResponseB\x1dZ\x1bgithub.com/google/gar/protob\x06proto3"var (file_proto_gar_proto_rawDescOnce sync.Once- file_proto_gar_proto_rawDescData = file_proto_gar_proto_rawDesc+ file_proto_gar_proto_rawDescData []byte)func file_proto_gar_proto_rawDescGZIP() []byte {file_proto_gar_proto_rawDescOnce.Do(func() {- file_proto_gar_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_gar_proto_rawDescData)+ file_proto_gar_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_proto_gar_proto_rawDesc), len(file_proto_gar_proto_rawDesc)))})return file_proto_gar_proto_rawDescData}var file_proto_gar_proto_enumTypes = make([]protoimpl.EnumInfo, 1)-var file_proto_gar_proto_msgTypes = make([]protoimpl.MessageInfo, 25)+var file_proto_gar_proto_msgTypes = make([]protoimpl.MessageInfo, 22)var file_proto_gar_proto_goTypes = []any{(State)(0), // 0: proto.State(*ProcessRequest)(nil), // 1: proto.ProcessRequest@@ -1858,66 +1470,59 @@ var file_proto_gar_proto_goTypes = []any{(*FunctionCallContent)(nil), // 7: proto.FunctionCallContent(*FunctionResponseContent)(nil), // 8: proto.FunctionResponseContent(*Content)(nil), // 9: proto.Content- (*SessionStateEvent)(nil), // 10: proto.SessionStateEvent- (*AgentCallEvent)(nil), // 11: proto.AgentCallEvent- (*HandoffEvent)(nil), // 12: proto.HandoffEvent- (*Event)(nil), // 13: proto.Event- (*HealthCheckRequest)(nil), // 14: proto.HealthCheckRequest- (*HealthCheckResponse)(nil), // 15: proto.HealthCheckResponse- (*TriggerSessionRequest)(nil), // 16: proto.TriggerSessionRequest- (*TriggerSessionResponse)(nil), // 17: proto.TriggerSessionResponse- (*ForkSessionRequest)(nil), // 18: proto.ForkSessionRequest- (*ForkSessionResponse)(nil), // 19: proto.ForkSessionResponse- (*RemoteAgentConfig)(nil), // 20: proto.RemoteAgentConfig- (*RegisterAgentRequest)(nil), // 21: proto.RegisterAgentRequest- (*RegisterAgentResponse)(nil), // 22: proto.RegisterAgentResponse- (*UnregisterAgentRequest)(nil), // 23: proto.UnregisterAgentRequest- (*UnregisterAgentResponse)(nil), // 24: proto.UnregisterAgentResponse- nil, // 25: proto.RegisterAgentRequest.MetadataEntry- (*structpb.Struct)(nil), // 26: google.protobuf.Struct- (*timestamppb.Timestamp)(nil), // 27: google.protobuf.Timestamp+ (*ExecutionEvent)(nil), // 10: proto.ExecutionEvent+ (*HealthCheckRequest)(nil), // 11: proto.HealthCheckRequest+ (*HealthCheckResponse)(nil), // 12: proto.HealthCheckResponse+ (*TriggerSessionRequest)(nil), // 13: proto.TriggerSessionRequest+ (*TriggerSessionResponse)(nil), // 14: proto.TriggerSessionResponse+ (*ForkSessionRequest)(nil), // 15: proto.ForkSessionRequest+ (*ForkSessionResponse)(nil), // 16: proto.ForkSessionResponse+ (*RemoteAgentConfig)(nil), // 17: proto.RemoteAgentConfig+ (*RegisterAgentRequest)(nil), // 18: proto.RegisterAgentRequest+ (*RegisterAgentResponse)(nil), // 19: proto.RegisterAgentResponse+ (*UnregisterAgentRequest)(nil), // 20: proto.UnregisterAgentRequest+ (*UnregisterAgentResponse)(nil), // 21: proto.UnregisterAgentResponse+ nil, // 22: proto.RegisterAgentRequest.MetadataEntry+ (*structpb.Struct)(nil), // 23: google.protobuf.Struct+ (*timestamppb.Timestamp)(nil), // 24: google.protobuf.Timestamp}var file_proto_gar_proto_depIdxs = []int32{9, // 0: proto.ProcessRequest.contents:type_name -> proto.Content9, // 1: proto.ProcessResponse.contents:type_name -> proto.Content4, // 2: proto.ConfirmationContent.approval:type_name -> proto.ApprovalDecision5, // 3: proto.ConfirmationContent.decline:type_name -> proto.DeclineDecision- 26, // 4: proto.FunctionCallContent.args:type_name -> google.protobuf.Struct- 26, // 5: proto.FunctionResponseContent.response:type_name -> google.protobuf.Struct+ 23, // 4: proto.FunctionCallContent.args:type_name -> google.protobuf.Struct+ 23, // 5: proto.FunctionResponseContent.response:type_name -> google.protobuf.Struct3, // 6: proto.Content.text:type_name -> proto.TextContent6, // 7: proto.Content.confirmation:type_name -> proto.ConfirmationContent7, // 8: proto.Content.function_call:type_name -> proto.FunctionCallContent8, // 9: proto.Content.function_response:type_name -> proto.FunctionResponseContent- 0, // 10: proto.SessionStateEvent.state:type_name -> proto.State- 9, // 11: proto.AgentCallEvent.contents:type_name -> proto.Content- 9, // 12: proto.HandoffEvent.contents:type_name -> proto.Content- 27, // 13: proto.Event.timestamp:type_name -> google.protobuf.Timestamp- 27, // 14: proto.Event.controller_timestamp:type_name -> google.protobuf.Timestamp- 10, // 15: proto.Event.session_state_event:type_name -> proto.SessionStateEvent- 11, // 16: proto.Event.agent_call_event:type_name -> proto.AgentCallEvent- 12, // 17: proto.Event.handoff_event:type_name -> proto.HandoffEvent- 9, // 18: proto.TriggerSessionRequest.inputs:type_name -> proto.Content- 9, // 19: proto.TriggerSessionResponse.outputs:type_name -> proto.Content- 0, // 20: proto.TriggerSessionResponse.state:type_name -> proto.State- 25, // 21: proto.RegisterAgentRequest.metadata:type_name -> proto.RegisterAgentRequest.MetadataEntry- 20, // 22: proto.RegisterAgentRequest.remote:type_name -> proto.RemoteAgentConfig- 1, // 23: proto.AgentService.Process:input_type -> proto.ProcessRequest- 14, // 24: proto.AgentService.HealthCheck:input_type -> proto.HealthCheckRequest- 16, // 25: proto.GARService.TriggerSession:input_type -> proto.TriggerSessionRequest- 18, // 26: proto.GARService.ForkSession:input_type -> proto.ForkSessionRequest- 21, // 27: proto.GARService.RegisterAgent:input_type -> proto.RegisterAgentRequest- 23, // 28: proto.GARService.UnregisterAgent:input_type -> proto.UnregisterAgentRequest- 2, // 29: proto.AgentService.Process:output_type -> proto.ProcessResponse- 15, // 30: proto.AgentService.HealthCheck:output_type -> proto.HealthCheckResponse- 17, // 31: proto.GARService.TriggerSession:output_type -> proto.TriggerSessionResponse- 19, // 32: proto.GARService.ForkSession:output_type -> proto.ForkSessionResponse- 22, // 33: proto.GARService.RegisterAgent:output_type -> proto.RegisterAgentResponse- 24, // 34: proto.GARService.UnregisterAgent:output_type -> proto.UnregisterAgentResponse- 29, // [29:35] is the sub-list for method output_type- 23, // [23:29] is the sub-list for method input_type- 23, // [23:23] is the sub-list for extension type_name- 23, // [23:23] is the sub-list for extension extendee- 0, // [0:23] is the sub-list for field type_name+ 9, // 10: proto.ExecutionEvent.inputs:type_name -> proto.Content+ 9, // 11: proto.ExecutionEvent.outputs:type_name -> proto.Content+ 0, // 12: proto.ExecutionEvent.state:type_name -> proto.State+ 24, // 13: proto.ExecutionEvent.timestamp:type_name -> google.protobuf.Timestamp+ 9, // 14: proto.TriggerSessionRequest.inputs:type_name -> proto.Content+ 9, // 15: proto.TriggerSessionResponse.outputs:type_name -> proto.Content+ 0, // 16: proto.TriggerSessionResponse.state:type_name -> proto.State+ 22, // 17: proto.RegisterAgentRequest.metadata:type_name -> proto.RegisterAgentRequest.MetadataEntry+ 17, // 18: proto.RegisterAgentRequest.remote:type_name -> proto.RemoteAgentConfig+ 1, // 19: proto.AgentService.Process:input_type -> proto.ProcessRequest+ 11, // 20: proto.AgentService.HealthCheck:input_type -> proto.HealthCheckRequest+ 13, // 21: proto.GARService.TriggerSession:input_type -> proto.TriggerSessionRequest+ 15, // 22: proto.GARService.ForkSession:input_type -> proto.ForkSessionRequest+ 18, // 23: proto.GARService.RegisterAgent:input_type -> proto.RegisterAgentRequest+ 20, // 24: proto.GARService.UnregisterAgent:input_type -> proto.UnregisterAgentRequest+ 2, // 25: proto.AgentService.Process:output_type -> proto.ProcessResponse+ 12, // 26: proto.AgentService.HealthCheck:output_type -> proto.HealthCheckResponse+ 14, // 27: proto.GARService.TriggerSession:output_type -> proto.TriggerSessionResponse+ 16, // 28: proto.GARService.ForkSession:output_type -> proto.ForkSessionResponse+ 19, // 29: proto.GARService.RegisterAgent:output_type -> proto.RegisterAgentResponse+ 21, // 30: proto.GARService.UnregisterAgent:output_type -> proto.UnregisterAgentResponse+ 25, // [25:31] is the sub-list for method output_type+ 19, // [19:25] is the sub-list for method input_type+ 19, // [19:19] is the sub-list for extension type_name+ 19, // [19:19] is the sub-list for extension extendee+ 0, // [0:19] is the sub-list for field type_name}func init() { file_proto_gar_proto_init() }@@ -1935,21 +1540,16 @@ func file_proto_gar_proto_init() {(*Content_FunctionCall)(nil),(*Content_FunctionResponse)(nil),}- file_proto_gar_proto_msgTypes[12].OneofWrappers = []any{- (*Event_SessionStateEvent)(nil),- (*Event_AgentCallEvent)(nil),- (*Event_HandoffEvent)(nil),- }- file_proto_gar_proto_msgTypes[20].OneofWrappers = []any{+ file_proto_gar_proto_msgTypes[17].OneofWrappers = []any{(*RegisterAgentRequest_Remote)(nil),}type x struct{}out := protoimpl.TypeBuilder{File: protoimpl.DescBuilder{GoPackagePath: reflect.TypeOf(x{}).PkgPath(),- RawDescriptor: file_proto_gar_proto_rawDesc,+ RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_gar_proto_rawDesc), len(file_proto_gar_proto_rawDesc)),NumEnums: 1,- NumMessages: 25,+ NumMessages: 22,NumExtensions: 0,NumServices: 2,},@@ -1959,7 +1559,6 @@ func file_proto_gar_proto_init() {MessageInfos: file_proto_gar_proto_msgTypes,}.Build()File_proto_gar_proto = out.File- file_proto_gar_proto_rawDesc = nilfile_proto_gar_proto_goTypes = nilfile_proto_gar_proto_depIdxs = nil}diff --git a/proto/gar.proto b/proto/gar.protoindex 3bd9e1d..5dfcb99 100644--- a/proto/gar.proto+++ b/proto/gar.proto@@ -23,27 +23,15 @@ option go_package = "github.com/google/gar/proto";// ProcessRequest is an input to an agent.message ProcessRequest {- // Checkpoint is the optional checkpoint associated with- // the contents.- string checkpoint_id = 1;-- // Contents as input.- repeated Content contents = 2;+ repeated Content contents = 1;}// ProcessResponse is an output from an agent.// It can be returned in a streaming fashion.message ProcessResponse {- // Checkpoint is the optional checkpoint associated with- // the contents.string checkpoint_id = 1;-- // Contents as output.repeated Content contents = 2;-- // Optional agent handoff. If set controller, hands off the- // execution to the provided agent.- string agent_handoff = 3;+ bool from_cache = 3;}// TextContent represents a text content.@@ -105,52 +93,17 @@ message Content {// fully compatible with the Interactions Content message.}-// Event that represents a session state change.-// Some sessions may not be resumable based on their latest state.-// For example, controller doesn't continue a session once-// the state is set to STATE_FAILED.-message SessionStateEvent {- State state = 1;-}--// AgentCallEvent represents an agent call.-message AgentCallEvent {- reserved 1, 2;- string sender = 3;- repeated Content contents = 4;- bool awaiting_more = 5;-- // TODO(jbd): Support pauses and async calls.-}--// HandoffEvent represents an agent handoff.-// Controller records the agent handoff with-// associated content.-message HandoffEvent {- reserved 1, 2;- string source_agent_id = 3;- string target_agent_id = 4;- repeated Content contents = 5;-}--// Event is the entry in the event log. Events are used-// to record the actions taken place in the GAR controller.-// GAR controller can replay the events for resumability.-message Event {- string session_id = 1;- string checkpoint_id = 2;-- string sender_name = 3;- string sender_id = 4;-- google.protobuf.Timestamp timestamp = 5;- google.protobuf.Timestamp controller_timestamp = 6;-- oneof kind {- SessionStateEvent session_state_event = 7; // TODO: remove- AgentCallEvent agent_call_event = 8;- HandoffEvent handoff_event = 9;- }+// ExecutionEvent is the entry in the event log. ExecutionEvents are used+// to record the actions taken place in the executor.+// The executor can replay the events for resumability.+message ExecutionEvent {+ string task_id = 2;+ string agent_id = 3;+ repeated Content inputs = 4;+ repeated Content outputs = 5;+ State state = 6;+ google.protobuf.Timestamp timestamp = 7;+ // string checkpoint_id = 10;}// HealthCheckRequest for agent health checks@@ -174,26 +127,23 @@ service AgentService {// State represents the state of a sessionenum State {STATE_UNSPECIFIED = 0; // Unspecified state- STATE_RUNNING = 1; // Session is currently running- STATE_FAILED = 2; // Session failed- STATE_COMPLETED = 3; // Completed, can accept new triggers-- // TODO(jbd): Add STATE_COMPLETED and only allow triggers if- // the state is STATE_UNSPECIFIED or STATE_COMPLETED.+ STATE_PENDING = 1;+ STATE_FAILED = 2;+ STATE_COMPLETED = 3;}// TriggerSessionRequest for triggering a new sessionmessage TriggerSessionRequest {string session_id = 1; // Unique session identifier- repeated Content inputs = 2; // Input content to process+ string agent_id = 2; // Agent ID, if empty planner is used.+ repeated Content inputs = 3; // Input content to process}// TriggerSessionResponse contains the result of triggering a sessionmessage TriggerSessionResponse {string session_id = 1; // Session ID (in case it was generated or modified by server)- string checkpoint_id = 2; // Current checkpoint ID- repeated Content outputs = 3; // Output content- State state = 4; // Session state+ repeated Content outputs = 2; // Output content+ State state = 3; // Session state}message ForkSessionRequest {diff --git a/proto/gar_grpc.pb.go b/proto/gar_grpc.pb.goindex 2ef8ed7..9bc654a 100644--- a/proto/gar_grpc.pb.go+++ b/proto/gar_grpc.pb.go@@ -14,8 +14,8 @@// Code generated by protoc-gen-go-grpc. DO NOT EDIT.// versions:-// - protoc-gen-go-grpc v1.5.1-// - protoc v5.28.2+// - protoc-gen-go-grpc v1.6.0+// - protoc v3.21.9// source: proto/gar.protopackage proto@@ -101,10 +101,10 @@ type AgentServiceServer interface {type UnimplementedAgentServiceServer struct{}func (UnimplementedAgentServiceServer) Process(grpc.BidiStreamingServer[ProcessRequest, ProcessResponse]) error {- return status.Errorf(codes.Unimplemented, "method Process not implemented")+ return status.Error(codes.Unimplemented, "method Process not implemented")}func (UnimplementedAgentServiceServer) HealthCheck(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {- return nil, status.Errorf(codes.Unimplemented, "method HealthCheck not implemented")+ return nil, status.Error(codes.Unimplemented, "method HealthCheck not implemented")}func (UnimplementedAgentServiceServer) mustEmbedUnimplementedAgentServiceServer() {}func (UnimplementedAgentServiceServer) testEmbeddedByValue() {}@@ -117,7 +117,7 @@ type UnsafeAgentServiceServer interface {}func RegisterAgentServiceServer(s grpc.ServiceRegistrar, srv AgentServiceServer) {- // If the following call pancis, it indicates UnimplementedAgentServiceServer was+ // If the following call panics, it indicates UnimplementedAgentServiceServer was// embedded by pointer and is nil. This will cause panics if an// unimplemented method is ever invoked, so we test this at initialization// time to prevent it from happening at runtime later due to I/O.@@ -282,16 +282,16 @@ type GARServiceServer interface {type UnimplementedGARServiceServer struct{}func (UnimplementedGARServiceServer) TriggerSession(*TriggerSessionRequest, grpc.ServerStreamingServer[TriggerSessionResponse]) error {- return status.Errorf(codes.Unimplemented, "method TriggerSession not implemented")+ return status.Error(codes.Unimplemented, "method TriggerSession not implemented")}func (UnimplementedGARServiceServer) ForkSession(context.Context, *ForkSessionRequest) (*ForkSessionResponse, error) {- return nil, status.Errorf(codes.Unimplemented, "method ForkSession not implemented")+ return nil, status.Error(codes.Unimplemented, "method ForkSession not implemented")}func (UnimplementedGARServiceServer) RegisterAgent(context.Context, *RegisterAgentRequest) (*RegisterAgentResponse, error) {- return nil, status.Errorf(codes.Unimplemented, "method RegisterAgent not implemented")+ return nil, status.Error(codes.Unimplemented, "method RegisterAgent not implemented")}func (UnimplementedGARServiceServer) UnregisterAgent(context.Context, *UnregisterAgentRequest) (*UnregisterAgentResponse, error) {- return nil, status.Errorf(codes.Unimplemented, "method UnregisterAgent not implemented")+ return nil, status.Error(codes.Unimplemented, "method UnregisterAgent not implemented")}func (UnimplementedGARServiceServer) mustEmbedUnimplementedGARServiceServer() {}func (UnimplementedGARServiceServer) testEmbeddedByValue() {}@@ -304,7 +304,7 @@ type UnsafeGARServiceServer interface {}func RegisterGARServiceServer(s grpc.ServiceRegistrar, srv GARServiceServer) {- // If the following call pancis, it indicates UnimplementedGARServiceServer was+ // If the following call panics, it indicates UnimplementedGARServiceServer was// embedded by pointer and is nil. This will cause panics if an// unimplemented method is ever invoked, so we test this at initialization// time to prevent it from happening at runtime later due to I/O.diff --git a/test_multi.go b/test_multi.goindex 464de35..c6c2dee 100644--- a/test_multi.go+++ b/test_multi.go@@ -40,7 +40,6 @@ func main() {// 2. Initialize controllerc, err := controller.New(ctx, controller.Config{- MaxSteps: 15,HealthCheck: config.HealthCheckConfig{Enabled: false, // disable to speed up},@@ -111,7 +110,7 @@ func main() {for i := 0; i < 4; i++ {log.Printf("\n--- Triggering step %d ---\n", i+1)- if err := c.TriggerSession(ctx, sessionID, req, handler); err != nil {+ if err := c.TriggerSession(ctx, sessionID, "", req, handler); err != nil {log.Fatalf("Error triggering session step %d: %v\n", i+1, err)}// Subsequent triggers just ask the planner to continue processing the existing history@@ -120,8 +119,8 @@ func main() {}func createLocalAgent() (*agent.LocalAgent, error) {- processFunc := func(ctx context.Context, sessionID string, incoming *proto.ProcessRequest, handler agent.OutputHandler) error {- for _, content := range incoming.Contents {+ processFunc := func(ctx context.Context, t *agent.Task, e agent.TaskExecutor, handler agent.OutputHandler) error {+ for _, content := range t.Inputs {textContent := content.GetText()if textContent == nil {continue@@ -156,51 +155,57 @@ func (m *mockPlanner) ID() string { return "__plannerfunc (m *mockPlanner) Name() string { return "Mock Planner" }func (m *mockPlanner) HealthCheck(ctx context.Context) error { return nil }func (m *mockPlanner) Close() error { return nil }-func (m *mockPlanner) Process(ctx context.Context, sessionID string, incoming *proto.ProcessRequest, handler agent.OutputHandler) error {+func (m *mockPlanner) Process(ctx context.Context, t *agent.Task, e agent.TaskExecutor, handler agent.OutputHandler) error {var lastText string- for _, c := range incoming.Contents {- if t := c.GetText(); t != nil {- lastText = t.Text+ for _, c := range t.Inputs {+ if textMsg := c.GetText(); textMsg != nil {+ lastText = textMsg.Text}}// Step 1: User -> Localif strings.HasPrefix(lastText, "Send the word") {- return handler(&proto.ProcessResponse{- AgentHandoff: "local-echo-agent",- Contents: []*proto.Content{{- Role: "assistant",- Content: &proto.Content_Text{- Text: &proto.TextContent{Text: "oRanGe"},- },- }},+ inputs := append(t.Inputs, &proto.Content{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{Text: "oRanGe"},+ },})+ return e.Exec(ctx, &agent.Task{+ ID: "local-echo",+ AgentID: "local-echo-agent",+ Inputs: inputs,+ }, handler)}// Step 2: Local -> Remoteif lastText == "orange" {- return handler(&proto.ProcessResponse{- AgentHandoff: "remote-text-processor",- Contents: []*proto.Content{{- Role: "assistant",- Content: &proto.Content_Text{- Text: &proto.TextContent{Text: lastText},- },- }},+ inputs := append(t.Inputs, &proto.Content{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{Text: lastText},+ },})+ return e.Exec(ctx, &agent.Task{+ ID: "remote-text",+ AgentID: "remote-text-processor",+ Inputs: inputs,+ }, handler)}// Step 3: Remote -> Sandboxif strings.HasPrefix(lastText, "Remote Prefix:") {- return handler(&proto.ProcessResponse{- AgentHandoff: "uppercase",- Contents: []*proto.Content{{- Role: "assistant",- Content: &proto.Content_Text{- Text: &proto.TextContent{Text: lastText},- },- }},+ inputs := append(t.Inputs, &proto.Content{+ Role: "assistant",+ Content: &proto.Content_Text{+ Text: &proto.TextContent{Text: lastText},+ },})+ return e.Exec(ctx, &agent.Task{+ ID: "uppercase-task",+ AgentID: "uppercase",+ Inputs: inputs,+ }, handler)}// Final step: Sandbox -> Done