-
Notifications
You must be signed in to change notification settings - Fork 852
feat: add task_card and plan blocks #1819
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
zimeg
merged 20 commits into
feat-ai-apps-thinking-steps
from
zimeg-feat-ai-apps-task-card-block
Jan 16, 2026
Merged
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c3bdb2d
feat: accept chunks as arguments to chat.{start,append,stop}Stream me…
zimeg 8c56e22
fix: remove unsupported and unused identifiers for full support
zimeg 783ada5
style: remove mypy extra ignore comment for overriden attributes
zimeg 1fb7355
test: confirm chunks parse as expected json values
zimeg 5de794b
feat: support and flush chunks in the chat stream helper
zimeg 61d6d53
test: dump chunks json before comparison for exact parsings
zimeg 85081e1
test: update async tests to expect chunks when flushing buffer
zimeg a6bb951
style: prefer using markdown text chunks in internal calls
zimeg 92c93e0
fix: support explicit json values as chunk objects
zimeg 9d40cb0
feat: add task_card block
zimeg 8745c7b
feat: export the task_card block from blocks
zimeg 6073ffe
refactor: move url source block element to documented elements
zimeg 17b75d7
feat: add plan block
zimeg 1184a8f
docs: add description to task_card block
zimeg 7a61bbf
fix: ignore overrides for specific attributes of block elements
zimeg bd9886c
test: confirm plan and task_card json is parsed as expected blocks
zimeg 2fc6abb
docs: include reference for the task_card status argument
zimeg 90fdd0c
chore: merge w main
zimeg 86101a2
chore: merge w base branch
zimeg 9a3e529
fix: import url source element to use in the file later
zimeg 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
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,155 @@ | ||
| import logging | ||
| from typing import Any, Dict, Optional, Sequence, Set, Union | ||
|
|
||
| from slack_sdk.errors import SlackObjectFormationError | ||
| from slack_sdk.models import show_unknown_key_warning | ||
| from slack_sdk.models.basic_objects import JsonObject | ||
|
|
||
|
|
||
| class Chunk(JsonObject): | ||
| """ | ||
| Chunk for streaming messages. | ||
|
|
||
| https://docs.slack.dev/messaging/sending-and-scheduling-messages#text-streaming | ||
| """ | ||
|
|
||
| attributes = {"type"} | ||
| logger = logging.getLogger(__name__) | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| type: Optional[str] = None, | ||
| ): | ||
| self.type = type | ||
|
|
||
| @classmethod | ||
| def parse(cls, chunk: Union[Dict, "Chunk"]) -> Optional["Chunk"]: | ||
| if chunk is None: | ||
| return None | ||
| elif isinstance(chunk, Chunk): | ||
| return chunk | ||
| else: | ||
| if "type" in chunk: | ||
| type = chunk["type"] | ||
| if type == MarkdownTextChunk.type: | ||
| return MarkdownTextChunk(**chunk) | ||
| elif type == TaskUpdateChunk.type: | ||
| return TaskUpdateChunk(**chunk) | ||
| else: | ||
| cls.logger.warning(f"Unknown chunk detected and skipped ({chunk})") | ||
| return None | ||
| else: | ||
| cls.logger.warning(f"Unknown chunk detected and skipped ({chunk})") | ||
| return None | ||
|
|
||
|
|
||
| class MarkdownTextChunk(Chunk): | ||
| type = "markdown_text" | ||
|
|
||
| @property | ||
| def attributes(self) -> Set[str]: # type: ignore[override] | ||
| return super().attributes.union({"text"}) | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| text: str, | ||
| **others: Dict, | ||
| ): | ||
| """Used for streaming text content with markdown formatting support. | ||
|
|
||
| https://docs.slack.dev/messaging/sending-and-scheduling-messages#text-streaming | ||
| """ | ||
| super().__init__(type=self.type) | ||
| show_unknown_key_warning(self, others) | ||
|
|
||
| self.text = text | ||
|
|
||
|
|
||
| class URLSource(JsonObject): | ||
| type = "url" | ||
|
|
||
| @property | ||
| def attributes(self) -> Set[str]: | ||
| return super().attributes.union( | ||
| { | ||
| "url", | ||
| "text", | ||
| "icon_url", | ||
| } | ||
| ) | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| url: str, | ||
| text: str, | ||
| icon_url: Optional[str] = None, | ||
| **others: Dict, | ||
| ): | ||
| show_unknown_key_warning(self, others) | ||
| self._url = url | ||
| self._text = text | ||
| self._icon_url = icon_url | ||
|
|
||
| def to_dict(self) -> Dict[str, Any]: | ||
| self.validate_json() | ||
| json: Dict[str, Union[str, Dict]] = { | ||
| "type": self.type, | ||
| "url": self._url, | ||
| "text": self._text, | ||
| } | ||
| if self._icon_url: | ||
| json["icon_url"] = self._icon_url | ||
| return json | ||
|
|
||
|
|
||
| class TaskUpdateChunk(Chunk): | ||
| type = "task_update" | ||
|
|
||
| @property | ||
| def attributes(self) -> Set[str]: # type: ignore[override] | ||
| return super().attributes.union( | ||
| { | ||
| "id", | ||
| "title", | ||
| "status", | ||
| "details", | ||
| "output", | ||
| "sources", | ||
| } | ||
| ) | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| id: str, | ||
| title: str, | ||
| status: str, # "pending", "in_progress", "complete", "error" | ||
| details: Optional[str] = None, | ||
| output: Optional[str] = None, | ||
| sources: Optional[Sequence[Union[Dict, URLSource]]] = None, | ||
| **others: Dict, | ||
| ): | ||
| """Used for displaying tool execution progress in a timeline-style UI. | ||
|
|
||
| https://docs.slack.dev/messaging/sending-and-scheduling-messages#text-streaming | ||
| """ | ||
| super().__init__(type=self.type) | ||
| show_unknown_key_warning(self, others) | ||
|
|
||
| self.id = id | ||
| self.title = title | ||
| self.status = status | ||
| self.details = details | ||
| self.output = output | ||
| if sources is not None: | ||
| self.sources = [] | ||
| for src in sources: | ||
| if isinstance(src, Dict): | ||
| self.sources.append(src) | ||
| elif isinstance(src, URLSource): | ||
| self.sources.append(src.to_dict()) | ||
| else: | ||
| raise SlackObjectFormationError(f"Unsupported type for source in task update chunk: {type(src)}") |
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
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.
🤔 thought: This is introduced in #1806 but I'm not certain if it's best kept with the "messages" model or if it should be included as a block element?
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.
🗣️ note: In 6073ffe it's moved to the block elements - the
urlsource can be used in standalone messages as well as in chunks.