__platform tag so the narrowing functions from platform narrowing can recover their platform-specific shapes.
Space
Every exposes the same interface regardless of platform:| Method | Description |
|---|---|
send(...content) | Send one or more content items into the conversation. |
edit(message, newContent) | Rewrite a previously-sent message. Sugar for send(edit(newContent, message)). |
unsend(message) | Retract a previously-sent message. Sugar for send(unsend(message)). |
startTyping() | Show a typing indicator. No-op if the platform doesn’t support it. |
stopTyping() | Hide the typing indicator. |
responding(fn) | Start a typing indicator, run fn, and stop the indicator when it completes — even if fn throws. |
getMessage(id) | Fetch a message by ID from the conversation. Throws UnsupportedError on platforms that don’t support it. |
getMembers() | List the chat’s current participants as Users, excluding the agent’s own account where identifiable. Throws UnsupportedError on platforms that can’t list members. |
getAvatar() | Download the chat avatar (group icon) as { data, mimeType }. Resolves undefined when none is set; throws UnsupportedError on platforms that can’t fetch avatars. |
rename(displayName) | Rename the chat. Sugar for send(rename(displayName)). |
avatar(input, options?) | Set or clear the chat avatar. Sugar for send(avatar(input, options?)). |
add(users) | Add members to the chat. Sugar for send(addMember(users)). |
remove(users) | Remove members from the chat. Sugar for send(removeMember(users)). |
leave() | Leave the chat with the agent’s own account. Sugar for send(leaveSpace()). |
User
Users are minimal: an ID and a platform tag.user.schema.
Typing indicators
Manual
space.send(typing("start")) and space.send(typing("stop")) — see Typing indicators for the canonical form.
Automatic with responding
responding is the recommended pattern. It guarantees the typing indicator is cleared even if the inner function throws:
Creating a space
To start a new conversation, use platform narrowing to get a platform instance, then callspace.create(...) with the users:
space.get(id):
type: "dm" | "group" on iMessage — but it also satisfies the generic Space interface, so send(), startTyping(), and friends are always available.