of yours).
slot="signed-out" replaces only the sign-in line: Polynet's "Sign in" button
and "New here? Join" link stay under it, so don't add your own.
Example, in your design's own layout:
The bench is clear. First sketch?
The guild
Where they usually go: a "room" (a page or section named in the
community's words) with channels beside the chat, and the people as a
column there or on their own page. On phones, one column:
polynet-channels::part(list) { grid-auto-flow: column; overflow-x: auto }
turns the channels into a scrolling row above the chat. Custom views (a
parade map, this week's lantern nights) are built with the SDK below, beside the
blocks, never instead of them.
## Blocks: events, learn, knowledge and ask
On Polynet's /events, /learn, /knowledge and /ask pages on every site, and
anywhere you place them. Like the others, signed out (or not a member) each
shows a sign-in and join prompt and never an event, course, memory or
conversation.
-
: upcoming events first, grouped by month, each with its
date, time in the event's own time zone and, when the member's differs,
their own ("7:00 – 8:30 PM GMT your time"), and where; one under way is
marked Now; past events (the last 90 days) are folded below. Each opens
at /events/ (in place on /events; Back returns): when, where, a
join link the organizer set, the description, "Add to calendar" (an .ics
file made in the page) and "Copy link". No RSVP. limit="3" shows only the
next three and a link to /events (for a home page).
- : the courses as cards (with lesson counts), a course's
lessons in order, and the lesson reader (markdown) with Previous and Next.
Each step is an address under /learn, in place on that page.
- : what the community knows, from its memory: the top
memories (title, kind, when it applies) and a search; each opens in place,
labelled "From the community's memory".
- : the member's private conversation with the community agent
(only they see it): the history, a box (Enter asks; Shift+Enter is a new
line), the reply as it streams, and starter questions while the
conversation is empty. If a question fails it goes back in the box with
Try again. Give it a height (it scrolls inside): polynet-ask { height:
70vh } is the default.
Each reflects its state on the tag: state="loading" | "ready" | "signed-out"
| "error" (events and learn also "missing", for an address that isn't there).
They take the same tokens; their ::part()s and slots are listed above.
## Block: discover
is on Polynet's /discover page on every site, and
anywhere you place it. It is public: signed in or not, it shows every
published community on Polynet (never unlisted ones) as a card with its
picture or initials, name, one-liner and member count, and a search by
name or one-liner. Each card opens that community's own site when it has
one, else its page on Polynet ("On Polynet" says so), in the same tab;
this site's own community is marked "You're here". limit="4" shows the
first four and a link to /discover (for a home page or a footer). The
list is at most a minute old. state="loading" | "ready" | "error".
## Errors
Failed calls throw PolynetError with .code, .message and .status. Codes:
- sign_in_required (status 401): the member is signed out or the session
expired. Show sign-in. session() then reads signed_in: false.
- not_ready: you called something before awaiting session().
- upload_failed, live_unavailable, agent_unavailable, agent_failed: show
.message and let the member retry.
- agent_off: the community agent is off here. Don't offer to retry; see
"The community agent".
- any other code (for example a permission or rate limit): show .message.
## Chat
- channels() -> [{ slug, name, path, isGeneral, canPost, canReply, unread,
mentioned, seenThroughAt }] (seenThroughAt: when the member last read it,
ms, or null). Use the one with isGeneral as the default. In your own
composer, hide posting when canPost is false and replying when canReply
is. unread: posts the member hasn't seen; mentioned: someone @mentioned
them there. markRead(channelSlug, throughAt?) clears both, up to now or up
to throughAt (the newest post they saw, or a time); call it when the member
is looking at the channel.
- feed(channelSlug, { limit, cursor }) -> the newest posts (default and at
most 50), oldest first (chat order; reverse() for newest-first). The list
has .cursor: pass it back (feed(slug, { cursor: posts.cursor })) for the
page before; null means you reached the start of the channel.
- thread(channelSlug, post.ref) -> the post, then its replies, oldest first:
the whole thread (the SDK follows the server's pages, up to 2,000 replies).
The list has .complete: false only when a thread is longer than that.
Each post or reply has:
ref // "interaction:root:" or "interaction:reply:"
path
text // the whole text (markdown); render this
snippet // the first 500 characters; snippet_truncated says if cut
actor // { type, display_name, handle, avatar_url, user_id, agent_key }
// all keys always present; the agent's name fields are null
reactions // [{ emoji, count }]
reacted_by_me // [emoji]
by_me // posted by or for the signed-in member: they may remove() it
can_edit // they may edit() it (their own words only)
reply_count // a number (0 on replies)
root_ref // on replies: the ref of their post
attachments // [{ ref, name, kind, mime, size }], kind "image" | "video" | "file"
edited_at // ISO time or null
created_at // ISO time
Writing:
- post(channelSlug, text, { replyTo: post.ref, files: [File], askAgent: true,
mentions: [member], key }) posts, or replies when replyTo is set. Returns
{ ref, path, ... }. mentions notifies members (from members()); the text
must contain each one's "@" + member.handle.
askAgent asks the community agent to answer in the channel; Polynet puts
"@ " in front of the text (unless it is already there),
which is how agent mentions read everywhere. The agent answers as a reply
in that post's thread: a site that asks it in public must show threads
(reply_count, thread()), or the answer never appears. Editing that post
later doesn't ask the agent again; keep the prefix in the edit box.
key (optional, 8-100 of A-Z a-z 0-9 _ -): your own idempotency key. Retry
a failed post with the same key, text and files and it never posts twice
(files already uploaded aren't sent again); make a new key for new
content.
- edit(post, text) when post.can_edit; remove(post) when post.by_me.
- react(ref, emoji, on) adds (on: true) or removes (on: false) the member's
reaction on a post or reply. Returns { reacted, reaction_summary }.
- fileUrl(attachment) -> a URL for
,