Update event schema types to use enum pattern (#7498)

Co-authored-by: Calvin Smith <calvin@all-hands.dev>
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
Calvin Smith 2025-03-25 15:36:13 -06:00 committed by GitHub
parent 500e09f12b
commit 78b67bc9d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 52 deletions

View File

@ -1,87 +1,83 @@
from pydantic import BaseModel, Field
__all__ = ['ActionType']
from enum import Enum
class ActionTypeSchema(BaseModel):
MESSAGE: str = Field(default='message')
class ActionType(str, Enum):
MESSAGE = 'message'
"""Represents a message.
"""
START: str = Field(default='start')
START = 'start'
"""Starts a new development task OR send chat from the user. Only sent by the client.
"""
READ: str = Field(default='read')
READ = 'read'
"""Reads the content of a file.
"""
WRITE: str = Field(default='write')
WRITE = 'write'
"""Writes the content to a file.
"""
EDIT: str = Field(default='edit')
EDIT = 'edit'
"""Edits a file by providing a draft.
"""
RUN: str = Field(default='run')
RUN = 'run'
"""Runs a command.
"""
RUN_IPYTHON: str = Field(default='run_ipython')
RUN_IPYTHON = 'run_ipython'
"""Runs a IPython cell.
"""
BROWSE: str = Field(default='browse')
BROWSE = 'browse'
"""Opens a web page.
"""
BROWSE_INTERACTIVE: str = Field(default='browse_interactive')
BROWSE_INTERACTIVE = 'browse_interactive'
"""Interact with the browser instance.
"""
DELEGATE: str = Field(default='delegate')
DELEGATE = 'delegate'
"""Delegates a task to another agent.
"""
THINK: str = Field(default='think')
THINK = 'think'
"""Logs a thought.
"""
FINISH: str = Field(default='finish')
FINISH = 'finish'
"""If you're absolutely certain that you've completed your task and have tested your work,
use the finish action to stop working.
"""
REJECT: str = Field(default='reject')
REJECT = 'reject'
"""If you're absolutely certain that you cannot complete the task with given requirements,
use the reject action to stop working.
"""
NULL: str = Field(default='null')
NULL = 'null'
PAUSE: str = Field(default='pause')
PAUSE = 'pause'
"""Pauses the task.
"""
RESUME: str = Field(default='resume')
RESUME = 'resume'
"""Resumes the task.
"""
STOP: str = Field(default='stop')
STOP = 'stop'
"""Stops the task. Must send a start action to restart a new task.
"""
CHANGE_AGENT_STATE: str = Field(default='change_agent_state')
CHANGE_AGENT_STATE = 'change_agent_state'
PUSH: str = Field(default='push')
PUSH = 'push'
"""Push a branch to github."""
SEND_PR: str = Field(default='send_pr')
SEND_PR = 'send_pr'
"""Send a PR to github."""
RECALL: str = Field(default='recall')
RECALL = 'recall'
"""Retrieves content from a user workspace, microagent, or other source."""
ActionType = ActionTypeSchema()

View File

@ -1,56 +1,51 @@
from pydantic import BaseModel, Field
__all__ = ['ObservationType']
from enum import Enum
class ObservationTypeSchema(BaseModel):
READ: str = Field(default='read')
class ObservationType(str, Enum):
READ = 'read'
"""The content of a file
"""
WRITE: str = Field(default='write')
WRITE = 'write'
EDIT: str = Field(default='edit')
EDIT = 'edit'
BROWSE: str = Field(default='browse')
BROWSE = 'browse'
"""The HTML content of a URL
"""
RUN: str = Field(default='run')
RUN = 'run'
"""The output of a command
"""
RUN_IPYTHON: str = Field(default='run_ipython')
RUN_IPYTHON = 'run_ipython'
"""Runs a IPython cell.
"""
CHAT: str = Field(default='chat')
CHAT = 'chat'
"""A message from the user
"""
DELEGATE: str = Field(default='delegate')
DELEGATE = 'delegate'
"""The result of a task delegated to another agent
"""
MESSAGE: str = Field(default='message')
MESSAGE = 'message'
ERROR: str = Field(default='error')
ERROR = 'error'
SUCCESS: str = Field(default='success')
SUCCESS = 'success'
NULL: str = Field(default='null')
NULL = 'null'
THINK: str = Field(default='think')
THINK = 'think'
AGENT_STATE_CHANGED: str = Field(default='agent_state_changed')
AGENT_STATE_CHANGED = 'agent_state_changed'
USER_REJECTED: str = Field(default='user_rejected')
USER_REJECTED = 'user_rejected'
CONDENSE: str = Field(default='condense')
CONDENSE = 'condense'
"""Result of a condensation operation."""
RECALL: str = Field(default='recall')
RECALL = 'recall'
"""Result of a recall operation. This can be the workspace context, a microagent, or other types of information."""
ObservationType = ObservationTypeSchema()