Documentation
¶
Overview ¶
Copyright 2026 Teradata
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 adapter provides adapters to bridge Crush's TUI interfaces with Loom's gRPC client. This allows the Crush TUI components to work with Loom's server without modification.
Copyright 2026 Teradata ¶
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.
Copyright 2026 Teradata ¶
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.
Copyright 2026 Teradata ¶
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.
Copyright 2026 Teradata ¶
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.
Copyright 2026 Teradata ¶
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.
Index ¶
- Constants
- Variables
- func HITLRequestToPermission(hitl *loomv1.HITLRequestInfo) permission.PermissionRequest
- func ProgressToMessage(progress *loomv1.WeaveProgress, sessionID string, messageID string, ...) message.Message
- func ProgressToMessageWithHistory(progress *loomv1.WeaveProgress, sessionID string, messageID string, ...) message.Message
- func ProtoToMessage(m *loomv1.Message, sessionID string) message.Message
- func ProtoToToolCall(tc *loomv1.ToolCall) message.ToolCall
- type AgentBusyError
- type AgentResult
- type ConfigOptions
- type CoordinatorAdapter
- func (c *CoordinatorAdapter) Cancel()
- func (c *CoordinatorAdapter) CancelAll()
- func (c *CoordinatorAdapter) ClearQueue(sessionID string)
- func (c *CoordinatorAdapter) GetAgentID() string
- func (c *CoordinatorAdapter) IsBusy(agentID string) bool
- func (c *CoordinatorAdapter) IsSessionBusy(sessionID string) bool
- func (c *CoordinatorAdapter) ListAgents(ctx context.Context) ([]agent.AgentInfo, error)
- func (c *CoordinatorAdapter) QueuedPrompts() int
- func (c *CoordinatorAdapter) QueuedPromptsList(sessionID string) []string
- func (c *CoordinatorAdapter) Run(ctx context.Context, sessionID, prompt string, attachments ...any) (any, error)
- func (c *CoordinatorAdapter) SetAgentID(agentID string)
- func (c *CoordinatorAdapter) Summarize(ctx context.Context, sessionID string) error
- func (c *CoordinatorAdapter) UpdateModels(ctx context.Context) error
- type CostInfo
- type EventSubscriber
- type LoomApp
- func (a *LoomApp) Client() *client.Client
- func (a *LoomApp) Config() *LoomConfig
- func (a *LoomApp) IsBusy() bool
- func (a *LoomApp) ListAgents(ctx context.Context) ([]*loomv1.AgentInfo, error)
- func (a *LoomApp) ListAvailableModels(ctx context.Context) ([]*loomv1.ModelInfo, error)
- func (a *LoomApp) SetAgentID(agentID string)
- func (a *LoomApp) Shutdown()
- func (a *LoomApp) Subscribe(program *tea.Program)
- func (a *LoomApp) SwitchModel(ctx context.Context, sessionID, provider, model string, role loomv1.LLMRole) (*loomv1.SwitchModelResponse, error)
- type LoomConfig
- type MessageAdapter
- type NoopCoordinator
- func (n *NoopCoordinator) Cancel()
- func (n *NoopCoordinator) CancelAll()
- func (n *NoopCoordinator) ClearQueue(sessionID string)
- func (n *NoopCoordinator) GetAgentID() string
- func (n *NoopCoordinator) IsBusy(agentID string) bool
- func (n *NoopCoordinator) IsSessionBusy(sessionID string) bool
- func (n *NoopCoordinator) ListAgents(ctx context.Context) ([]agent.AgentInfo, error)
- func (n *NoopCoordinator) QueuedPrompts() int
- func (n *NoopCoordinator) QueuedPromptsList(sessionID string) []string
- func (n *NoopCoordinator) Run(ctx context.Context, sessionID, prompt string, attachments ...any) (any, error)
- func (n *NoopCoordinator) SetAgentID(agentID string)
- func (n *NoopCoordinator) Summarize(ctx context.Context, sessionID string) error
- func (n *NoopCoordinator) UpdateModels(ctx context.Context) error
- type NoopMessageAdapter
- func (n *NoopMessageAdapter) Create(ctx context.Context, msg message.Message) error
- func (n *NoopMessageAdapter) Delete(ctx context.Context, messageID string) error
- func (n *NoopMessageAdapter) Get(ctx context.Context, messageID string) (message.Message, error)
- func (n *NoopMessageAdapter) List(ctx context.Context, sessionID string) ([]message.Message, error)
- func (n *NoopMessageAdapter) Subscribe(ctx context.Context) <-chan pubsub.Event[message.Message]
- func (n *NoopMessageAdapter) Update(ctx context.Context, msg message.Message) error
- type NoopSessionAdapter
- func (n *NoopSessionAdapter) Create(ctx context.Context, title string) (session.Session, error)
- func (n *NoopSessionAdapter) CreateAgentToolSessionID(messageID, toolCallID string) string
- func (n *NoopSessionAdapter) Delete(ctx context.Context, sessionID string) error
- func (n *NoopSessionAdapter) Get(ctx context.Context, sessionID string) (session.Session, error)
- func (n *NoopSessionAdapter) List(ctx context.Context) ([]session.Session, error)
- func (n *NoopSessionAdapter) ParseAgentToolSessionID(sessionID string) (string, string, bool)
- func (n *NoopSessionAdapter) SetAgentID(agentID string)
- func (n *NoopSessionAdapter) Subscribe(ctx context.Context) <-chan pubsub.Event[session.Session]
- func (n *NoopSessionAdapter) Update(ctx context.Context, sess session.Session) error
- type PermissionAdapter
- func (p *PermissionAdapter) AddPendingRequest(perm permission.PermissionRequest)
- func (p *PermissionAdapter) AutoApproveSession(sessionID string)
- func (p *PermissionAdapter) Deny(perm permission.PermissionRequest)
- func (p *PermissionAdapter) GetPendingRequest(toolCallID string) *permission.PermissionRequest
- func (p *PermissionAdapter) Grant(perm permission.PermissionRequest)
- func (p *PermissionAdapter) GrantPersistent(perm permission.PermissionRequest)
- func (p *PermissionAdapter) IsGranted(toolCallID string) bool
- func (p *PermissionAdapter) IsPersistentlyGranted(toolName string) bool
- func (p *PermissionAdapter) SetSkipRequests(skip bool)
- func (p *PermissionAdapter) SkipRequests() bool
- func (p *PermissionAdapter) Subscribe(ctx context.Context) <-chan pubsub.Event[permission.PermissionRequest]
- func (p *PermissionAdapter) SubscribeNotifications(ctx context.Context) <-chan pubsub.Event[permission.PermissionNotification]
- type ProgressEvent
- type SessionAdapter
- func (s *SessionAdapter) Create(ctx context.Context, title string) (session.Session, error)
- func (s *SessionAdapter) CreateAgentToolSessionID(messageID, toolCallID string) string
- func (s *SessionAdapter) Delete(ctx context.Context, id string) error
- func (s *SessionAdapter) Get(ctx context.Context, id string) (session.Session, error)
- func (s *SessionAdapter) List(ctx context.Context) ([]session.Session, error)
- func (s *SessionAdapter) ParseAgentToolSessionID(sessionID string) (string, string, bool)
- func (s *SessionAdapter) SetAgentID(agentID string)
- func (s *SessionAdapter) Subscribe(ctx context.Context) <-chan pubsub.Event[session.Session]
- type StageInfo
- type TUIOptions
- type UpdateAvailableMsg
Constants ¶
const ( TopicMessages = "tui.messages" TopicSessions = "tui.sessions" TopicPermissions = "tui.permissions" TopicProgress = "tui.progress" )
Topics for TUI events when using Loom's MessageBus.
Variables ¶
var ErrAgentBusy = &AgentBusyError{}
ErrAgentBusy is returned when trying to run while already busy.
Functions ¶
func HITLRequestToPermission ¶
func HITLRequestToPermission(hitl *loomv1.HITLRequestInfo) permission.PermissionRequest
HITLRequestToPermission converts a HITL request to a permission.PermissionRequest.
func ProgressToMessage ¶
func ProgressToMessage(progress *loomv1.WeaveProgress, sessionID string, messageID string, agentID string) message.Message
ProgressToMessage converts a WeaveProgress to a message.Message for display. The messageID parameter should be consistent across all progress events for the same turn. Deprecated: Use ProgressToMessageWithHistory for better progress tracking.
func ProgressToMessageWithHistory ¶
func ProgressToMessageWithHistory(progress *loomv1.WeaveProgress, sessionID string, messageID string, agentID string, startTimestamp int64, history []StageInfo) message.Message
ProgressToMessageWithHistory converts a WeaveProgress to a message.Message with stage history. Shows completed stages with ⏺ and the current stage with ◌ (spinner). The startTimestamp should be the timestamp of the first progress event in this turn for accurate duration calculation.
func ProtoToMessage ¶
ProtoToMessage converts a proto Message to internal message.Message type.
Types ¶
type AgentBusyError ¶
type AgentBusyError struct{}
AgentBusyError indicates the agent is already processing.
func (*AgentBusyError) Error ¶
func (e *AgentBusyError) Error() string
type AgentResult ¶
AgentResult represents the result of an agent run.
type ConfigOptions ¶
type ConfigOptions struct {
Editor string
InitializeAs string
TUI TUIOptions
}
ConfigOptions holds TUI options.
type CoordinatorAdapter ¶
type CoordinatorAdapter struct {
// contains filtered or unexported fields
}
CoordinatorAdapter wraps the gRPC client for agent coordination. Implements agent.Coordinator interface.
func NewCoordinatorAdapter ¶
func NewCoordinatorAdapter(c *client.Client, events chan<- tea.Msg) *CoordinatorAdapter
NewCoordinatorAdapter creates a new coordinator adapter.
func (*CoordinatorAdapter) Cancel ¶
func (c *CoordinatorAdapter) Cancel()
Cancel cancels the current agent's processing.
func (*CoordinatorAdapter) CancelAll ¶
func (c *CoordinatorAdapter) CancelAll()
CancelAll cancels all active agent processing.
func (*CoordinatorAdapter) ClearQueue ¶
func (c *CoordinatorAdapter) ClearQueue(sessionID string)
ClearQueue clears the prompt queue for a session.
func (*CoordinatorAdapter) GetAgentID ¶
func (c *CoordinatorAdapter) GetAgentID() string
GetAgentID returns the current agent ID.
func (*CoordinatorAdapter) IsBusy ¶
func (c *CoordinatorAdapter) IsBusy(agentID string) bool
IsBusy returns true if the specified agent is processing. If agentID is empty, checks if the default agent is busy.
func (*CoordinatorAdapter) IsSessionBusy ¶
func (c *CoordinatorAdapter) IsSessionBusy(sessionID string) bool
IsSessionBusy returns true if the agent associated with the given session is busy.
func (*CoordinatorAdapter) ListAgents ¶
ListAgents returns the list of available agents from the server.
func (*CoordinatorAdapter) QueuedPrompts ¶
func (c *CoordinatorAdapter) QueuedPrompts() int
QueuedPrompts returns the number of queued prompts.
func (*CoordinatorAdapter) QueuedPromptsList ¶
func (c *CoordinatorAdapter) QueuedPromptsList(sessionID string) []string
QueuedPromptsList returns the list of queued prompts for a session.
func (*CoordinatorAdapter) Run ¶
func (c *CoordinatorAdapter) Run(ctx context.Context, sessionID, prompt string, attachments ...any) (any, error)
Run starts agent processing for a prompt. Implements agent.Coordinator interface. Attachments[0] can be the agent ID if provided.
func (*CoordinatorAdapter) SetAgentID ¶
func (c *CoordinatorAdapter) SetAgentID(agentID string)
SetAgentID sets the default agent ID for operations.
func (*CoordinatorAdapter) Summarize ¶
func (c *CoordinatorAdapter) Summarize(ctx context.Context, sessionID string) error
Summarize is a stub for context summarization.
func (*CoordinatorAdapter) UpdateModels ¶
func (c *CoordinatorAdapter) UpdateModels(ctx context.Context) error
UpdateModels is a stub - Loom handles model updates differently.
type CostInfo ¶
type CostInfo struct {
TotalCost float64
InputTokens int32
OutputTokens int32
Provider string
Model string
}
CostInfo represents cost information.
type EventSubscriber ¶
EventSubscriber defines a function that returns an event channel. Matches Crush's subscription pattern.
type LoomApp ¶
type LoomApp struct {
// Services matching Crush's App interface
Sessions *SessionAdapter
Messages *MessageAdapter
Permissions *PermissionAdapter
// Agent coordinator wrapping gRPC streaming
AgentCoordinator *CoordinatorAdapter
// contains filtered or unexported fields
}
LoomApp adapts Loom's gRPC client to match Crush's app.App interface. This allows Crush TUI components to work seamlessly with Loom's server.
func NewLoomApp ¶
NewLoomApp creates a new LoomApp wrapping the gRPC client.
func (*LoomApp) Config ¶
func (a *LoomApp) Config() *LoomConfig
Config returns the application configuration.
func (*LoomApp) ListAgents ¶
ListAgents returns available agents from the server.
func (*LoomApp) ListAvailableModels ¶
ListAvailableModels returns available models from the server.
func (*LoomApp) SetAgentID ¶
SetAgentID sets the current agent/thread ID.
func (*LoomApp) Shutdown ¶
func (a *LoomApp) Shutdown()
Shutdown performs a graceful shutdown of the application.
func (*LoomApp) Subscribe ¶
Subscribe sends events to the TUI as tea.Msgs. Matches Crush's app.Subscribe interface.
func (*LoomApp) SwitchModel ¶
func (a *LoomApp) SwitchModel(ctx context.Context, sessionID, provider, model string, role loomv1.LLMRole) (*loomv1.SwitchModelResponse, error)
SwitchModel switches the model for a session. role specifies which LLM role to switch (0/unspecified = main agent LLM for backward compatibility).
type LoomConfig ¶
type LoomConfig struct {
ServerAddr string
WorkingDir string
AgentID string // Selected agent/thread
Options ConfigOptions
}
LoomConfig holds TUI configuration.
type MessageAdapter ¶
type MessageAdapter struct {
// contains filtered or unexported fields
}
MessageAdapter wraps the gRPC client for message operations. Implements message.Service interface.
func NewMessageAdapter ¶
func NewMessageAdapter(c *client.Client) *MessageAdapter
NewMessageAdapter creates a new message adapter.
type NoopCoordinator ¶ added in v1.1.0
type NoopCoordinator struct {
// contains filtered or unexported fields
}
NoopCoordinator is a no-op coordinator for when server is unavailable.
func (*NoopCoordinator) Cancel ¶ added in v1.1.0
func (n *NoopCoordinator) Cancel()
func (*NoopCoordinator) CancelAll ¶ added in v1.1.0
func (n *NoopCoordinator) CancelAll()
func (*NoopCoordinator) ClearQueue ¶ added in v1.1.0
func (n *NoopCoordinator) ClearQueue(sessionID string)
func (*NoopCoordinator) GetAgentID ¶ added in v1.1.0
func (n *NoopCoordinator) GetAgentID() string
func (*NoopCoordinator) IsBusy ¶ added in v1.1.0
func (n *NoopCoordinator) IsBusy(agentID string) bool
func (*NoopCoordinator) IsSessionBusy ¶ added in v1.1.0
func (n *NoopCoordinator) IsSessionBusy(sessionID string) bool
func (*NoopCoordinator) ListAgents ¶ added in v1.1.0
func (*NoopCoordinator) QueuedPrompts ¶ added in v1.1.0
func (n *NoopCoordinator) QueuedPrompts() int
func (*NoopCoordinator) QueuedPromptsList ¶ added in v1.1.0
func (n *NoopCoordinator) QueuedPromptsList(sessionID string) []string
func (*NoopCoordinator) SetAgentID ¶ added in v1.1.0
func (n *NoopCoordinator) SetAgentID(agentID string)
func (*NoopCoordinator) Summarize ¶ added in v1.1.0
func (n *NoopCoordinator) Summarize(ctx context.Context, sessionID string) error
func (*NoopCoordinator) UpdateModels ¶ added in v1.1.0
func (n *NoopCoordinator) UpdateModels(ctx context.Context) error
type NoopMessageAdapter ¶ added in v1.1.0
type NoopMessageAdapter struct{}
NoopMessageAdapter is a no-op message adapter for when server is unavailable.
func (*NoopMessageAdapter) Delete ¶ added in v1.1.0
func (n *NoopMessageAdapter) Delete(ctx context.Context, messageID string) error
type NoopSessionAdapter ¶ added in v1.1.0
type NoopSessionAdapter struct {
// contains filtered or unexported fields
}
NoopSessionAdapter is a no-op session adapter for when server is unavailable.
func (*NoopSessionAdapter) CreateAgentToolSessionID ¶ added in v1.1.0
func (n *NoopSessionAdapter) CreateAgentToolSessionID(messageID, toolCallID string) string
func (*NoopSessionAdapter) Delete ¶ added in v1.1.0
func (n *NoopSessionAdapter) Delete(ctx context.Context, sessionID string) error
func (*NoopSessionAdapter) ParseAgentToolSessionID ¶ added in v1.1.0
func (n *NoopSessionAdapter) ParseAgentToolSessionID(sessionID string) (string, string, bool)
func (*NoopSessionAdapter) SetAgentID ¶ added in v1.1.0
func (n *NoopSessionAdapter) SetAgentID(agentID string)
type PermissionAdapter ¶
type PermissionAdapter struct {
// contains filtered or unexported fields
}
PermissionAdapter manages permission requests for tool execution. Implements permission.Service interface. In Loom, HITL requests come via WeaveProgress, not a separate permission system.
func NewPermissionAdapter ¶
func NewPermissionAdapter() *PermissionAdapter
NewPermissionAdapter creates a new permission adapter.
func (*PermissionAdapter) AddPendingRequest ¶
func (p *PermissionAdapter) AddPendingRequest(perm permission.PermissionRequest)
AddPendingRequest adds a pending permission request.
func (*PermissionAdapter) AutoApproveSession ¶
func (p *PermissionAdapter) AutoApproveSession(sessionID string)
AutoApproveSession enables auto-approval for a session.
func (*PermissionAdapter) Deny ¶
func (p *PermissionAdapter) Deny(perm permission.PermissionRequest)
Deny denies a permission request.
func (*PermissionAdapter) GetPendingRequest ¶
func (p *PermissionAdapter) GetPendingRequest(toolCallID string) *permission.PermissionRequest
GetPendingRequest gets a pending request by tool call ID.
func (*PermissionAdapter) Grant ¶
func (p *PermissionAdapter) Grant(perm permission.PermissionRequest)
Grant grants a one-time permission.
func (*PermissionAdapter) GrantPersistent ¶
func (p *PermissionAdapter) GrantPersistent(perm permission.PermissionRequest)
GrantPersistent grants a persistent permission for a tool.
func (*PermissionAdapter) IsGranted ¶
func (p *PermissionAdapter) IsGranted(toolCallID string) bool
IsGranted checks if a tool call is granted.
func (*PermissionAdapter) IsPersistentlyGranted ¶
func (p *PermissionAdapter) IsPersistentlyGranted(toolName string) bool
IsPersistentlyGranted checks if a tool has persistent permission.
func (*PermissionAdapter) SetSkipRequests ¶
func (p *PermissionAdapter) SetSkipRequests(skip bool)
SetSkipRequests enables/disables auto-approval mode.
func (*PermissionAdapter) SkipRequests ¶
func (p *PermissionAdapter) SkipRequests() bool
SkipRequests returns whether auto-approval is enabled.
func (*PermissionAdapter) Subscribe ¶
func (p *PermissionAdapter) Subscribe(ctx context.Context) <-chan pubsub.Event[permission.PermissionRequest]
Subscribe subscribes to permission request events. Note: In Loom, HITL requests come via WeaveProgress streaming.
func (*PermissionAdapter) SubscribeNotifications ¶
func (p *PermissionAdapter) SubscribeNotifications(ctx context.Context) <-chan pubsub.Event[permission.PermissionNotification]
SubscribeNotifications subscribes to permission notification events.
type ProgressEvent ¶
type ProgressEvent struct {
Progress *loomv1.WeaveProgress
}
ProgressEvent wraps a WeaveProgress for TUI consumption.
type SessionAdapter ¶
type SessionAdapter struct {
// contains filtered or unexported fields
}
SessionAdapter wraps the gRPC client for session operations. Implements session.Service interface.
func NewSessionAdapter ¶
func NewSessionAdapter(c *client.Client) *SessionAdapter
NewSessionAdapter creates a new session adapter.
func (*SessionAdapter) CreateAgentToolSessionID ¶
func (s *SessionAdapter) CreateAgentToolSessionID(messageID, toolCallID string) string
CreateAgentToolSessionID is a stub for compatibility.
func (*SessionAdapter) Delete ¶
func (s *SessionAdapter) Delete(ctx context.Context, id string) error
Delete removes a session.
func (*SessionAdapter) ParseAgentToolSessionID ¶
func (s *SessionAdapter) ParseAgentToolSessionID(sessionID string) (string, string, bool)
ParseAgentToolSessionID is a stub for compatibility. Returns false since Loom handles agent sessions differently.
func (*SessionAdapter) SetAgentID ¶
func (s *SessionAdapter) SetAgentID(agentID string)
SetAgentID sets the agent ID for session operations.
type StageInfo ¶
type StageInfo struct {
Stage loomv1.ExecutionStage
Message string
ToolName string // Tool name for TOOL_EXECUTION stages
Content string // Actual content for LLM_GENERATION stages
Failed bool // Whether this stage failed
Done bool
}
StageInfo tracks information about a completed or current execution stage
type UpdateAvailableMsg ¶
UpdateAvailableMsg is sent when an update is available. Matches Crush's pubsub.UpdateAvailableMsg.