-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add kanban protocols and hook events (praisonai-agents core SDK) #1721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3856a8f
feat: add kanban protocols and hook events for praisonaiagents core SDK
praisonai-triage-agent[bot] e042eaf
test: fix HookEvent serialization assertion for Enum semantics
Copilot 7b2a4cc
test: verify HookEvent JSON serialization round-trip
Copilot ac2d643
fix: split kanban protocol optional methods into extension protocols
praisonai-triage-agent[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| """ | ||
| Kanban protocols and types for PraisonAI Agents. | ||
|
|
||
| This module provides the protocol contracts for kanban functionality, | ||
| allowing the wrapper (praisonai) and PraisonAIUI to share a stable | ||
| interface without coupling the core to SQLite or other heavy implementations. | ||
| """ | ||
|
|
||
| from praisonaiagents.kanban.protocols import ( | ||
| KanbanStoreProtocol, | ||
| KanbanTaskProtocol, | ||
| KanbanCommentingProtocol, | ||
| KanbanLinkingProtocol, | ||
| VALID_KANBAN_STATUSES, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "KanbanStoreProtocol", | ||
| "KanbanTaskProtocol", | ||
| "KanbanCommentingProtocol", | ||
| "KanbanLinkingProtocol", | ||
| "VALID_KANBAN_STATUSES", | ||
| ] |
221 changes: 221 additions & 0 deletions
221
src/praisonai-agents/praisonaiagents/kanban/protocols.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,221 @@ | ||
| """ | ||
| Kanban protocols for PraisonAI Agents. | ||
|
|
||
| Defines the protocol contracts that the wrapper (praisonai) and PraisonAIUI | ||
| can use to implement kanban functionality with a stable interface. | ||
|
|
||
| This follows AGENTS.md §3.2 Protocol-First Design: | ||
| - Protocols define WHAT (interface contract) | ||
| - Implementations define HOW (concrete behavior) | ||
| - Core SDK has protocols only, wrapper has heavy implementations | ||
| """ | ||
|
|
||
| from typing import Protocol, TypedDict, runtime_checkable | ||
|
|
||
|
|
||
| # Valid kanban statuses matching PraisonAIUI columns + archived | ||
| VALID_KANBAN_STATUSES: frozenset[str] = frozenset([ | ||
| "triage", | ||
| "todo", | ||
| "ready", | ||
| "running", | ||
| "blocked", | ||
| "review", | ||
| "done", | ||
| "archived" | ||
| ]) | ||
|
|
||
|
|
||
| class KanbanTaskProtocol(TypedDict, total=False): | ||
| """Typed dict shape for kanban task fields. | ||
|
|
||
| Defines the expected structure of task objects returned by | ||
| KanbanStoreProtocol implementations. | ||
| """ | ||
| id: str | ||
| title: str | ||
| body: str | ||
| status: str | ||
| assignee: str | None | ||
| priority: str | None | ||
| tenant: str | None | ||
| board: str | ||
| created_at: float | ||
| updated_at: float | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class KanbanStoreProtocol(Protocol): | ||
| """Protocol contract for kanban store implementations. | ||
|
|
||
| This protocol defines the core interface that PraisonAIUI expects | ||
| for injected kanban stores. Wrapper implementations must | ||
| implement all methods to be compatible. | ||
|
|
||
| Duck typing contract matches InjectedKanbanStore in PraisonAIUI. | ||
| """ | ||
|
|
||
| def get_board( | ||
| self, | ||
| *, | ||
| board: str = "default", | ||
| tenant: str | None = None, | ||
| include_archived: bool = False, | ||
| ) -> dict: | ||
| """Get board data with tasks grouped by status. | ||
|
|
||
| Args: | ||
| board: Board name (default: "default") | ||
| tenant: Optional tenant filter | ||
| include_archived: Whether to include archived tasks | ||
|
|
||
| Returns: | ||
| Board data with tasks organized by status columns | ||
| """ | ||
| ... | ||
|
|
||
| def get_task(self, task_id: str) -> dict | None: | ||
| """Get a single task by ID. | ||
|
|
||
| Args: | ||
| task_id: Task identifier | ||
|
|
||
| Returns: | ||
| Task data or None if not found | ||
| """ | ||
| ... | ||
|
|
||
| def create_task(self, data: dict) -> dict: | ||
| """Create a new task. | ||
|
|
||
| Args: | ||
| data: Task creation data (title, body, status, etc.) | ||
|
|
||
| Returns: | ||
| Created task data with assigned ID | ||
| """ | ||
| ... | ||
|
|
||
| def update_task(self, task_id: str, data: dict) -> dict | None: | ||
| """Update an existing task. | ||
|
|
||
| Args: | ||
| task_id: Task identifier | ||
| data: Fields to update | ||
|
|
||
| Returns: | ||
| Updated task data or None if not found | ||
| """ | ||
| ... | ||
|
|
||
| def move_task(self, task_id: str, status: str) -> dict | None: | ||
| """Move a task to a different status. | ||
|
|
||
| Args: | ||
| task_id: Task identifier | ||
| status: New status (must be in VALID_KANBAN_STATUSES) | ||
|
|
||
| Returns: | ||
| Updated task data or None if not found | ||
| """ | ||
| ... | ||
|
|
||
| def bulk_update(self, task_ids: list[str], status: str) -> dict: | ||
| """Update multiple tasks to the same status. | ||
|
|
||
| Args: | ||
| task_ids: List of task identifiers | ||
| status: New status for all tasks | ||
|
|
||
| Returns: | ||
| Results summary with success/failure counts | ||
| """ | ||
| ... | ||
|
|
||
| def delete_task(self, task_id: str) -> bool: | ||
| """Delete a task. | ||
|
|
||
| Args: | ||
| task_id: Task identifier | ||
|
|
||
| Returns: | ||
| True if deleted, False if not found | ||
| """ | ||
| ... | ||
|
|
||
| def list_events(self, since: float = 0.0, board: str = "default") -> list[dict]: | ||
| """List kanban events since a timestamp. | ||
|
|
||
| Args: | ||
| since: Unix timestamp to filter events from | ||
| board: Board name to filter events | ||
|
|
||
| Returns: | ||
| List of event data | ||
| """ | ||
| ... | ||
|
|
||
| def health(self) -> dict: | ||
| """Check store health status. | ||
|
|
||
| Returns: | ||
| Health status information | ||
| """ | ||
| ... | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class KanbanCommentingProtocol(Protocol): | ||
| """Extension protocol for kanban task commenting functionality. | ||
|
|
||
| This protocol is implemented separately from KanbanStoreProtocol to allow | ||
| stores to optionally support commenting without breaking isinstance checks | ||
| on the core protocol. | ||
| """ | ||
|
|
||
| def add_comment(self, task_id: str, text: str, author: str | None = None) -> dict | None: | ||
| """Add a comment to a task. | ||
|
|
||
| Args: | ||
| task_id: Task identifier | ||
| text: Comment text | ||
| author: Optional comment author | ||
|
|
||
| Returns: | ||
| Comment data or None if task not found | ||
| """ | ||
| ... | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class KanbanLinkingProtocol(Protocol): | ||
| """Extension protocol for kanban task linking functionality. | ||
|
|
||
| This protocol is implemented separately from KanbanStoreProtocol to allow | ||
| stores to optionally support task relationships without breaking isinstance | ||
| checks on the core protocol. | ||
| """ | ||
|
|
||
| def link_tasks(self, parent_id: str, child_id: str) -> bool: | ||
| """Link two tasks in parent-child relationship. | ||
|
|
||
| Args: | ||
| parent_id: Parent task identifier | ||
| child_id: Child task identifier | ||
|
|
||
| Returns: | ||
| True if linked successfully, False otherwise | ||
| """ | ||
| ... | ||
|
|
||
| def unlink_tasks(self, parent_id: str, child_id: str) -> bool: | ||
| """Unlink parent-child task relationship. | ||
|
|
||
| Args: | ||
| parent_id: Parent task identifier | ||
| child_id: Child task identifier | ||
|
|
||
| Returns: | ||
| True if unlinked successfully, False otherwise | ||
| """ | ||
| ... | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add async variants for store I/O contract methods.
Line 58-Line 164 define only synchronous store operations (
get_board,get_task,create_task, etc.). For core SDK contracts, this forces async callers toward blocking adapters and violates the SDK async I/O requirement. Add async counterparts (e.g.,aget_task,acreate_task, etc.) or a dedicated async protocol.As per coding guidelines,
All I/O operations must have both sync and async variants; never block the event loop with sync I/O in async context; use asyncio primitives for coordination, not threading.🤖 Prompt for AI Agents