pi-roundtable 0.45.1 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/docs/plugins.md +32 -7
  3. package/package.json +1 -1
  4. package/src/characters/compose.ts +7 -3
  5. package/src/characters/index.ts +1 -0
  6. package/src/characters/parts-face.ts +4 -1
  7. package/src/core/agents/agent-claim.ts +2 -2
  8. package/src/core/agents/agent-group-store.ts +74 -1
  9. package/src/core/agents/agent-places.ts +32 -0
  10. package/src/core/agents/agent-ports.ts +0 -94
  11. package/src/core/agents/agent-prompt.ts +3 -1
  12. package/src/core/agents/agent-team-fixture.ts +48 -7
  13. package/src/core/agents/agent-team.ts +54 -59
  14. package/src/core/agents/agent-tools.ts +34 -166
  15. package/src/core/agents/message-target.ts +3 -2
  16. package/src/core/agents/routes.ts +2 -1
  17. package/src/core/agents/team-editing.ts +121 -150
  18. package/src/core/agents/team-helpers.ts +80 -59
  19. package/src/core/agents/team-keys.ts +16 -26
  20. package/src/core/agents/team-lifecycle.ts +155 -99
  21. package/src/core/agents/team-looks.ts +102 -0
  22. package/src/core/agents/team-options.ts +12 -11
  23. package/src/core/agents/team-place-writes.ts +193 -0
  24. package/src/core/agents/team-places.ts +30 -0
  25. package/src/core/agents/team-posts.ts +42 -73
  26. package/src/core/agents/team-selection.ts +10 -2
  27. package/src/core/agents/team-status.ts +3 -2
  28. package/src/core/agents/team-text.ts +13 -46
  29. package/src/core/agents/team-turn-types.ts +11 -16
  30. package/src/core/agents/team-turns.ts +7 -6
  31. package/src/core/builtin/agent-server-options.ts +27 -6
  32. package/src/core/builtin/agent-server.ts +65 -69
  33. package/src/core/builtin/discord.ts +58 -8
  34. package/src/core/builtin/modules.ts +2 -0
  35. package/src/core/contract/agent-channels.ts +97 -0
  36. package/src/core/contract/channels.ts +10 -4
  37. package/src/core/contract/discord-key.ts +15 -0
  38. package/src/core/contract/places.ts +8 -2
  39. package/src/core/db/legacy-channels.ts +31 -0
  40. package/src/core/discord/agent-dashboard-service.ts +55 -0
  41. package/src/core/{agents → discord}/agent-dashboard.ts +7 -2
  42. package/src/core/discord/agent-discord.ts +1 -1
  43. package/src/core/discord/agent-guild.ts +87 -0
  44. package/src/core/{agents/team-layout.ts → discord/agent-layout.ts} +9 -29
  45. package/src/core/discord/agent-places.ts +52 -33
  46. package/src/core/discord/agent-tools.ts +210 -0
  47. package/src/core/discord/connection.ts +4 -1
  48. package/src/core/discord/discord-surface.ts +9 -14
  49. package/src/core/discord/place-fake-client.ts +59 -0
  50. package/src/core/host/define-roundtable.ts +7 -5
  51. package/src/core/modules/delegation/delegator.ts +5 -0
  52. package/src/core/plugin-api/agent-ops.ts +123 -0
  53. package/src/core/plugin-api/agent-server-ids.ts +9 -0
  54. package/src/core/plugin-api/define.ts +9 -0
  55. package/src/core/plugin-api/plugin.ts +2 -0
  56. package/src/core/plugin-api/services.ts +6 -0
  57. package/src/core/registry/contributions.ts +3 -0
  58. package/src/core/routing/channel-queue.ts +28 -12
  59. package/src/core/runtime/pi-agent-runtime.ts +1 -1
  60. package/src/core/runtime/runtime-plugin.ts +1 -0
  61. package/src/core/runtime/runtime-types.ts +6 -0
  62. package/src/core/{agents/agent-team-fake-channels.ts → testing/fake-agent-channels.ts} +5 -1
  63. package/src/core/testing/fake-pager-places.ts +16 -2
  64. package/src/core/testing/modules.ts +2 -1
  65. package/src/core/testing/place-contract.ts +3 -2
  66. package/src/core/testing/team-places.ts +75 -7
  67. package/src/core/testing/test-host.ts +20 -16
  68. package/src/discord/index.ts +5 -0
  69. package/src/kit/channels.ts +1 -2
  70. package/src/kit/support.ts +9 -5
package/CHANGELOG.md CHANGED
@@ -5,6 +5,47 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.46.0] - 2026-11-10
9
+
10
+ ### Added
11
+
12
+ - The chat home's knights move by part. A pin and a room row turn the head and sweep the held item with what the agent does: a glance now and then at rest, a ponder while thinking, a nod with the item's sweep while working, a cocked head and a raised item while a card waits, a nod and a flourish when a turn is done, a shake and a dropped item on an error, and a dozing head when it is sleepy; a new message perks the head up and hops the item. Rows at rest stay still inside and only breathe, a group's members each move their parts with the group's state, and reduced motion stops all of it.
13
+ - The accent badge's disc and ring stay still now: only the figure breathes, pops and squashes on them. A figure no longer sways as a whole while its agent works, and a pin you hold to move is no longer squashed.
14
+ - `pi-roundtable/characters` groups the head's parts (`head`, `hat`, `eyes-brows`, `mouth`, `fx`, `acc`) in one `<g class="hd" data-part="headset">`, and the hair behind the head carries class `hd` too, so a stylesheet can turn the head as one piece; the pixels of a figure do not change. `PIVOTS.neck` (`50px 76px`) is the pivot to turn it about, and `PIVOTS` is exported.
15
+ - The pins in the phone home's dock, with no room open, are drawn at 80 px as designed (they were 56 px by mistake), and the dock gives each one the room.
16
+
17
+ ### Changed
18
+
19
+ - Discord's two agent tools, `channel_arrange` and `channel_read`, and the `category` argument of `agent_create` and `group_create` are now contributed by the Discord plugin when the host has `discord.guild`; the team code no longer names them. Their names, text, tiers (`channel_read` member, `channel_arrange` admin) and the withholding from temp knights are unchanged, and an agent's turn is the only one that carries them, as before.
20
+ - `defineTool` takes `withheldFromHelpers`, which keeps a plugin's tool out of temp knights' turns, and the creation tools take the arguments a place provider adds with `createArguments`, passed on as `hints`. `AgentOps.create` and `createGroup` take `hints`; their `category`, `NewAgent.category` and the group's `category` still work, are passed on as `hints.category`, and are deprecated in favor of it, removed in 1.0.
21
+ - `AgentOps.arrange` and `AgentOps.read` are deprecated and removed in 1.0: the Discord plugin's `channel_arrange` and `channel_read` took their place. Until then the agent server's team still answers them, with what the two tools do on a host with `discord.guild`, and with the refusal 0.45 gave on a host whose team has no Discord channels.
22
+ - `AgentChannels`, `AgentPost`, `CategoryLayout`, `ChannelMessage` and `DashboardBoard` are Discord's agent guild internals; their export from `pi-roundtable/kit` is deprecated and moves to `pi-roundtable/discord` in 1.0.
23
+ - The `#dashboard` message in the agent guild is now kept by the Discord plugin instead of the agent server: it starts when the agent server's `team` service is ready and refreshes when the team changes, with the same text. The `dashboard` contribution lines are unchanged, and `agent_list` still ends with the categories section, now written by Discord's place provider.
24
+ - A plugin that replaces `DISCORD` on a host with `discord.guild` now contributes Discord's side of the agent guild itself, since the built-in Discord plugin is left out whole: spread `discordAgentGuild(context, { guild, connection, entryChannel })` from `pi-roundtable/discord` (`DiscordAgentGuildOptions`, `DiscordAgentGuild`) into what its setup returns. It holds the place provider, `channel_arrange` and `channel_read`, and the `#dashboard` message, names the coordinator's place from `entryChannel`, and writes the names in `agent_list`'s categories section; the built-in plugin contributes the same. A replacement that contributes only `discordPlaceProvider` has no channel tools and no dashboard, its coordinator is the first seeded agent, and its `agent_list` shows channel mentions. The startup refusal for a guild whose places no plugin serves names the guild's id and `discordAgentGuild`.
25
+ - The agent server's plugin imports nothing of Discord. The Discord plugin takes `entryChannel` (with `agentGuild`) and gives it through its place provider as the coordinator's place, and the agent server takes `placeSpaces`, the spaces its stored places live in, in place of `guildId`. `AgentServerOptions.guildId` and `entryChannelId` still work and are deprecated, removed in 1.0; the configuration keys and their messages are unchanged. The agents' channel context is read through `CHANNEL_CONTEXT`, from the surface that holds the message's channel.
26
+ - pi-roundtable-web: On a phone or tablet, the room drawer of a host with the chat home is laid out like the home: the folder tabs (open on the tab the home last had), the home's rows with the preview, time and unread counts, other folders' unread rooms, the pinned rooms in a dock at the bottom, and a bar with Home, the search and the add menu. The open room's dispatch threads head the list, so another thread of the room is one swipe and one tap away. A swipe left over a row closes the drawer and never turns Yolo on. The "Waiting for you" section and dropping a room into a folder are gone from this drawer; the room header's waiting button and the hold menu do both. Hosts that keep the rooms page and desktop widths keep today's drawer.
27
+ - pi-roundtable-web: The chat home's folder tabs scroll sideways on a phone again instead of wrapping onto a second line.
28
+ - The agent team makes, brings back, keeps and posts in the places of its agents and groups through the place providers. At start it asks each stored provider to make a place for every active agent that has none (a temp knight lives in its rooms until reached), and checks the places it has stored: one the provider finds gone archives its owner, as a deletion does. A place whose check fails is logged and kept as it is, and the start goes on; a provider without `check` leaves a group's place as it leaves an agent's. A group's topic follows its members through the provider. Creating, archiving, restoring and deleting an agent or group, a temp knight's thread, a reply and the interim posts of a turn all go through the provider of the place, so a chat network the core has never heard of gets its agents' places made, answered in, closed, brought back and archived on deletion with no change to the core. The agent server no longer listens for deleted Discord channels itself: the team registers with each provider's `onRemoved`.
29
+ - A team whose id stays while its agent guild changes no longer archives every agent at start. Its stored channels are another server's, which Discord's provider calls `foreign`: the rows are dropped and the places are made again in the agent guild. This holds when the bot has left the former server too: Discord's Missing Access for a channel the agent guild does not list counts as foreign. A temp knight's thread of a server the bot left is dropped and not made again.
30
+ - `PlaceProvider.remove` now resolves to the rest of the archive tool's answer after `Archived "<name>"`, starting with its own separator (`; its channel <#id> is kept under Archive.`), so a place that could not be kept can say so in the tool's own words (a line with no separator of its own is given `; `). A Discord connection without `createThread` makes no temp knight from a Discord conversation. A replacement Discord surface without `supportsFiles` refuses reply files in agent turns. The answers the tools give are unchanged. The agent store gains `setPlace` and `clearPlace` for the place an agent or group has on any surface, written beside the legacy `channelId` column of the Discord surface. The team classes are no longer Discord-named internally; `discordKey` moved to `src/core/contract/discord-key.ts` and `pi-roundtable/kit` still exports it.
31
+
32
+ ### Fixed
33
+
34
+ - pi-roundtable-coding: `DEFAULT_TOOL_TEXT` is frozen at every depth, so writing into it throws instead of changing the wording of every later `coding()` in the process; a spread of it, as the README shows, still composes.
35
+ - During the shutdown drain, the report turn of work that finished (delivered through `context.queue.finishing`) still runs, but it can no longer start team turns, delegated tasks, or transient tasks: a queue task that its own task starts is refused, and a transient or delegated task is refused while the new `QueuePort.draining` reads true, which `finishing` does not mask.
36
+ - pi-roundtable-drawing: `toolText` no longer accepts a name `Object.prototype` has (`toString`, `constructor`) as a tool, a misspelled `draw_cards` argument stops the start even when the host has no decks, and `DEFAULT_DRAWING_TOOL_TEXT` is frozen at every depth, so writing into it throws instead of changing the wording of every later `drawing()` in the process; a spread of it still composes.
37
+
38
+ ## [0.45.2] - 2026-11-10
39
+
40
+ ### Changed
41
+
42
+ - pi-roundtable-web: Every agent picture in the app is one accent badge: the figure stands free on a soft disc of the agent's accent, ringed in it, in the chat list, the pins, the side list, a room's header, the messages and everywhere else. The accent is lifted to 3:1 on the page, so a dark palette such as sable stays visible at night.
43
+ - pi-roundtable-web: The Camelot look no longer draws the gold disc or the heraldic shield around a figure on the page; `useCharacterStyle()` loses `frame` and `frameOf` is gone. `RoomPicture` and `CharacterStack` lose `bare`, and `PageCharacter` no longer takes `bare`; `Character` gains `badge`.
44
+
45
+ ### Fixed
46
+
47
+ - pi-roundtable-web: A pin on the chat home moves among the pins again: a hold (or a mouse drag) lifts it, the other pins make room across the grid or along the phone's dock, and letting go over a place puts it there; letting go in place still opens its menu.
48
+
8
49
  ## [0.45.1] - 2026-11-10
9
50
 
10
51
  ### Changed
package/docs/plugins.md CHANGED
@@ -1397,7 +1397,7 @@ export function turnLog(lines: string[]) {
1397
1397
  <!-- /example -->
1398
1398
 
1399
1399
  `serviceStarted` names the plugin and the service.
1400
- When the agent server's channels and dashboard are up, it reports `AGENT_SERVER_PLUGIN` and `AGENT_TEAM_SERVICE` (`"agent-server"` and `"team"`) with `outcome === "ready"`.
1400
+ When the agent server's team is up, with its places made and checked, it reports `AGENT_SERVER_PLUGIN` and `AGENT_TEAM_SERVICE` (`"agent-server"` and `"team"`) with `outcome === "ready"`. The Discord plugin starts the dashboard message on that event, so the dashboard comes after it.
1401
1401
  Wait for that event to do something that needs the team running, such as posting a notice.
1402
1402
 
1403
1403
  A turn event has a `kind`: `"agent"` for an agent's turn, else the kind the turn ran as (`"study"` in the example below).
@@ -1445,7 +1445,7 @@ A service has a name and optional `start`, `stop`, and `busy`.
1445
1445
  Services start once everything is set up and stop in reverse order.
1446
1446
  `busy` lists the work still running, one entry each; a shutdown waits until every service's list is empty, for at most the drain limit (three minutes by default, `drainSeconds` in the config), so a deploy rarely cuts work short.
1447
1447
  `beginDrain`, when the service has it, is called once as the shutdown begins to wait, before `busy` is first read: from then on the service starts no work of its own, such as a queued task.
1448
- `abort`, when the service has it, is called once at the drain limit if the service still lists work: it tells that work to stop gently, as the owner's stop does a turn, and returns whether it told any. The host then waits the abort grace (`drain.abortGraceMs`) for `busy` to empty before it calls `stop`, so `stop` need not be the first signal. A report that work sends as it ends goes through `context.queue.finishing(task)` (absent on a host that predates it; call the task directly then): a queue task started inside it is admitted although the host is shutting down, until the drain ends.
1448
+ `abort`, when the service has it, is called once at the drain limit if the service still lists work: it tells that work to stop gently, as the owner's stop does a turn, and returns whether it told any. The host then waits the abort grace (`drain.abortGraceMs`) for `busy` to empty before it calls `stop`, so `stop` need not be the first signal. A report that work sends as it ends goes through `context.queue.finishing(task)` (absent on a host that predates it; call the task directly then): a queue task started inside it is admitted although the host is shutting down, until the drain ends. The report's own turn runs, but what it spawns does not: a queue task that task starts is refused, and a transient task (`runTask`) is refused as long as `context.queue.draining` reads true, which `finishing` does not mask.
1449
1449
  The host adds its own channel queue to that wait, so a surface that queues its turns through `context.queue` needs no `busy` for them.
1450
1450
 
1451
1451
  A service may also have `startInBackground`.
@@ -2217,7 +2217,7 @@ export const echo = (tickets: Set<string>) =>
2217
2217
 
2218
2218
  ### `dashboard`: lines on the dashboard message
2219
2219
 
2220
- The agent server keeps a dashboard message pinned in Discord that shows the team's state.
2220
+ On a host with `discord.guild`, the Discord plugin keeps a dashboard message pinned in the agent guild that shows the team's state; it starts once the agent server's team is ready.
2221
2221
  Each string here is added under its title, in plugin order.
2222
2222
 
2223
2223
  <!-- example: examples/dashboard.ts -->
@@ -3250,9 +3250,29 @@ A provider is `derived` when the place exists with the name (a room, `<surface>:
3250
3250
  The members a minimal provider needs are `surface`, `storage`, `key`, `placeOf` and `post`; `ensure`, `remove`, `check` (`ok`, `gone` or `foreign`), `describe`, `onRemoved`, `interim`, `space`, `mention`, `conversations`, `coordinatorPlace`, `createArguments` and `layoutText` are optional capabilities.
3251
3251
  A surface with `agentRooms: true` and no provider gets a derived one from the host, so a surface written before places needs no change.
3252
3252
  The Discord plugin contributes its own when `discord.guild` is set.
3253
- A plugin that replaces `DISCORD` with a Discord of its own, on a host with `discord.guild`, contributes `discordPlaceProvider({ guild, connection, logger })` from `pi-roundtable/discord` with `places`: it gives the guild's channels the keys, group seats and log names the built-in Discord gives them (pass `client` too to have the team check its stored channels at start). Without a provider for the `discord` surface the host refuses to start, since the team would make channels it cannot read.
3253
+ A plugin that replaces `DISCORD` with a Discord of its own leaves the built-in Discord plugin out whole, and with it everything that plugin gives the agent team. On a host with `discord.guild` the replacement contributes Discord's side of the agent guild itself, by spreading `discordAgentGuild(context, { guild, connection, entryChannel })` from `pi-roundtable/discord` into what its setup returns:
3254
3254
 
3255
- The agent team reads its places through the providers: the keys of an agent or group (`AGENTS.team.roomsOf(name)`, and `placesOf(name)` with each key's surface), who owns a key (`AGENTS.team.owns(key)`, and `AGENTS.directory.placeOwner(key)` for an archived owner too), the routing table, the conversation keys of a group's seats and log, and the outbox replay. A stored provider's places are the rows of `agent_places`; a derived provider's are rooms. "Auto" order puts every stored place before the rooms, so with Discord configured the Discord channel is still an agent's primary place. A row of a surface no provider serves on this host is kept and ignored. `TeamStatus` views carry `places` (`TeamPlace`: `{ surface, key }`). `Agent.channelId`, `AgentGroup.channelId`, `AgentDirectory.agentByChannel` and `groupByChannel`, `AgentTeam.guildId` and `discordGuild`, and the status views' `channelId` are deprecated and removed in 1.0; the team still writes them. Writes (making, archiving and posting in places) still go through Discord's channels directly.
3255
+ ```ts
3256
+ setup: (context) => {
3257
+ context.services.provide(DISCORD, { connection, /* ... */ });
3258
+ return {
3259
+ surfaces: [surface],
3260
+ ...discordAgentGuild(context, { guild, connection, entryChannel }),
3261
+ };
3262
+ },
3263
+ ```
3264
+
3265
+ It returns four contributions, the same the built-in plugin makes:
3266
+
3267
+ - `places`: the provider that gives the guild's channels the keys, group seats and log names the built-in Discord gives them, names the coordinator's place from `entryChannel`, and writes the categories section of `agent_list` with the agents' and groups' names. Pass `client` too to have the team check its stored channels at start.
3268
+ - `tools`: `channel_arrange` and `channel_read`, which an agent's turn carries.
3269
+ - `services` and `events`: the `#dashboard` message over `connection.agentDashboard(guild)`, started when the agent server's team is ready. A plugin with services or event handlers of its own merges them with these.
3270
+
3271
+ `guild` and `entryChannel` are the host's `discord.guild` and `discord.entryChannel`. Without `entryChannel` the coordinator is the first agent the host seeds, since a host with `discord.guild` names no coordinator in its configuration. `discordPlaceProvider({ guild, connection, logger })` is the provider alone: a replacement that contributes only it has no channel tools and no dashboard, and its `agent_list` shows channel mentions where the names were. Without a provider for the `discord` surface the host refuses to start, since the team would make channels it cannot read.
3272
+
3273
+ The agent team reads its places through the providers: the keys of an agent or group (`AGENTS.team.roomsOf(name)`, and `placesOf(name)` with each key's surface), who owns a key (`AGENTS.team.owns(key)`, and `AGENTS.directory.placeOwner(key)` for an archived owner too), the routing table, the conversation keys of a group's seats and log, and the outbox replay. A stored provider's places are the rows of `agent_places`; a derived provider's are rooms. "Auto" order puts every stored place before the rooms, so with Discord configured the Discord channel is still an agent's primary place. A row of a surface no provider serves on this host is kept and ignored. `TeamStatus` views carry `places` (`TeamPlace`: `{ surface, key }`). `Agent.channelId`, `AgentGroup.channelId`, `AgentDirectory.agentByChannel` and `groupByChannel`, `AgentTeam.guildId` and `discordGuild`, and the status views' `channelId` are deprecated and removed in 1.0; the team still writes them.
3274
+
3275
+ The team writes through the providers too. At start it calls `ensure` for each active agent without a place on a stored provider (a temp knight lives in its rooms until reached) and `check` for each place it has stored: `gone` archives the owner as a deletion does, and `foreign` (an id that is no place of the provider's space, such as a channel of a guild the team left) drops the row and makes a new place with `ensure`. Creating an agent or group makes its place with `ensure` (the values of a provider's `createArguments` arrive as `hints`), a temp knight's thread is made with `ensure` and `parent`, archiving calls `remove`, restoring calls `ensure` with `existing`, a group's topic is written with `describe`, and a place the provider reports through `onRemoved` archives its owner. `remove` resolves to the rest of the archive tool's answer after `Archived "<name>"`, starting with its own separator (`; its channel <#id> is kept under Archive.`), or to nothing. Replies and interim posts go through `post` and `interim`, and a reply carries files only where the place's surface declares `supportsFiles`.
3256
3276
 
3257
3277
  `placeProviderContract(name, make)` from `pi-roundtable/testing` registers the provider contract as tests for any provider; `make` returns a `PlaceContractSubject` with the provider and a view of what a person on the surface sees.
3258
3278
 
@@ -3686,7 +3706,7 @@ A host that keeps Discord may write it as an adapter instead, as [`adapters`](#a
3686
3706
  - `coordinator` names the agent that coordinates the team; it must be one of `agents` and defaults to the first. With `discord.guild` the agent in `discord.entryChannel` is the coordinator, and `coordinator` is a `ConfigError`. The coordinator cannot be archived. `AGENTS.team.coordinator()` answers with either.
3687
3707
  - The team's id is `LOCAL_TEAM_ID`, `"local"`, where Discord's is the guild's id; the rows are stored under it as under the guild's, and `AGENTS.team.guildId` is it.
3688
3708
  - The start fails, naming the fix ("agents need a surface that hosts their rooms, such as pi-roundtable-web"), when no installed surface declares `agentRooms`: without Discord channels the agents could never be spoken to. The check runs when the plugins are linked, so a surface added by any plugin counts.
3689
- - No channel is made, checked or arranged, and the dashboard (a Discord message) does not exist. `channel_arrange` and `channel_read` are not offered, and `agent_create` and `group_create` take no `category`; called anyway through `AgentTeam`, arranging and reading answer that the host has no Discord channels. `agent_create` and `group_create` make no channel, and a new agent starts its opening task in its room on the first surface that hosts rooms. Archiving an agent or group stops its rooms from answering.
3709
+ - No channel is made, checked or arranged, and the dashboard (a Discord message) does not exist. `channel_arrange` and `channel_read` are not offered, since the Discord plugin contributes them only with `discord.guild`, and `agent_create` and `group_create` take no `category`. `AgentTeam` has no arranging or reading; the deprecated `AgentOps.arrange` and `AgentOps.read` of `pi-roundtable/kit`, called anyway, answer that the host has no Discord channels. `agent_create` and `group_create` make no channel, and a new agent starts its opening task in its room on the first surface that hosts rooms. Archiving an agent or group stops its rooms from answering.
3690
3710
  - `category` on `agent_create` and `group_create`, offered only to a team with Discord channels, places a Discord channel. Their `group` places the new room in a group of the app's room list through `ROOM_LAYOUT`, made when missing; without `group` the room stays ungrouped. `agent_list` ends with the app's groups and pinned rooms, and `room_arrange { groups: [{ group, names }] }` sorts rooms into groups the way `channel_arrange` sorts channels into categories, an owner's tool like it. On a host without the app's room list, `group` and `room_arrange` are refused before anything is made.
3691
3711
  - An agent's pictures have no public address unless `http.publicUrl` is set: `AGENTS.avatars.url(hash)` is then the path `/avatars/<hash>.png`, which the surface serves itself through `AGENTS.avatars.serve(pathname)` under its own origin, as the web console does. With `http.publicUrl` they are served on the `public` listener as with Discord.
3692
3712
  - `AgentTeam.channelOf(name, near?)` answers with the agent's room on the surface of `near` (the asker's own conversation) when that surface hosts rooms, so `schedule_list` from a room reads the room's schedules; for an agent with no Discord channel it falls back to its room on the first surface that hosts rooms. The status the dashboard and the web read counts an agent's schedules, waiting turns and context use across its Discord channel and its rooms.
@@ -3879,6 +3899,7 @@ The parts are medieval: the clothes, hats and gear of an agent are what a late-m
3879
3899
  | `composeSvg(spec, options?)` | The picture as an SVG string, see below |
3880
3900
  | `accentOf(spec, on)` | `colors.primary` as a UI accent: shaded until it reads at 3:1 on the page. `on` is a scheme (`light`: white, `dark`: `#0d1018`) or a look (`modern-light`, `modern-dark` as the schemes; `camelot-light`: the darkest parchment `#e3d2a9`, `camelot-dark`: the lightest night blue `#243557`) |
3881
3901
  | `characterCss()` | The text of `characters.css` |
3902
+ | `PIVOTS` | Where a stylesheet turns each part, as CSS `transform-origin` values in the drawing's 100-unit space: `eyes`, `badge`, `orbit`, `character` (the feet) and `neck`, which is the pivot of the head group (`.hd`). `characters.css` uses all but `neck`; a page that moves the head writes its own rule with it |
3882
3903
  | `checkSkins(value, field?)` | A host's skin tones checked: exactly six `#rrggbb` colors, returned lower-cased and frozen; otherwise a `CharacterError` whose `field` is `field` (default `skins`) or the place in the list. The host's configuration and `composeSvg` call it |
3883
3904
  | `EAST_ASIAN_SKINS` | Six light East Asian skin tones, from very fair porcelain to light beige (`#fbebe0`, `#f8e1d2`, `#f5d8c5`, `#f1cfb8`, `#edc6ac`, `#e9bf9f`), warm pink to peach and never green or yellow, with the face lines reading on each at 5:1 or better. A frozen constant for a host's `characters.skins` |
3884
3905
 
@@ -3888,7 +3909,7 @@ The parts are medieval: the clothes, hats and gear of an agent are what a late-m
3888
3909
 
3889
3910
  `ComposeOptions` are all optional: `expr` (one of the 13 `EXPRESSIONS`, by default the one `STATE_EXPRESSION` gives the state), `state` (one of the seven `AVATAR_STATES`: `idle`, `thinking`, `working`, `waiting`, `done`, `error`, `sleepy`), `look` (`modern-light` by default, `modern-dark`, `camelot-light` or `camelot-dark`, which change only the background and ring), `frame` (`disc` or `shield`), `bare` (no frame or background), `mouth` (`open` or `closed`, drawn in place of the expression's own mouth, for the two frames of a talking figure), `still`, `uid`, `size`, `label` and `skins` (six `#rrggbb` skin tones that `CharacterSpec.skin` indexes, in place of `CATALOG.skins`; anything but six valid colors throws a `CharacterError` whose `field` is `skins` or `skins[3]`).
3890
3911
 
3891
- - The output has literal colors only. It has no `style` attribute, variable, `<style>`, script, text, image, link, event handler or `<foreignObject>`, so a page whose content security policy forbids inline styles can inject it, and `canvas` rasterizes it as it is. It is at most 8 KB and the same for the same input. The root is `<svg class="av" data-expr>` and the layers are `<g class="NAME" data-part="NAME">` in a fixed order (`frame`, `ch` holding `back`, `body`, `head`, `hat`, `eyes-brows`, `mouth`, `fx`, `acc`, `prop`, then `state`); the prop group carries `data-prop`.
3912
+ - The output has literal colors only. It has no `style` attribute, variable, `<style>`, script, text, image, link, event handler or `<foreignObject>`, so a page whose content security policy forbids inline styles can inject it, and `canvas` rasterizes it as it is. It is at most 8 KB and the same for the same input. The root is `<svg class="av" data-expr>` and the layers are `<g class="NAME" data-part="NAME">` in a fixed order (`frame`, `ch` holding `back`, `body`, `headset`, `prop`, then `state`); `headset` (class `hd`) holds `head`, `hat`, `eyes-brows`, `mouth`, `fx` and `acc`, and `back` carries class `hd` too, so one rule turns the hair behind the head with the head about `PIVOTS.neck`; the prop group carries `data-prop`.
3892
3913
  - `composeSvg` checks the spec again with `parseCharacter`, so a spec cast from untrusted data throws instead of reaching the markup. `uid` (`/^[a-z0-9]{1,16}$/`, default `a`) ends every clip path id, so each avatar on a page needs its own `uid`: two with the same one share clip path ids and one clips the other. The server-side renders pass an explicit one. `size` (an integer up to 4096) adds `width` and `height`, which `canvas` needs. `label` (at most 200 characters) becomes `aria-label` with `<>"'=()&` written as entities; without it the figure is `aria-hidden`.
3893
3914
  - A live figure carries every state overlay and leaves the motion to the stylesheet. With `still: true` only the `state`'s overlay is drawn and the figure has class `av static`, for files, PNGs and 3D textures; an `error` state turns the ring red in both.
3894
3915
 
@@ -5136,6 +5157,8 @@ Import from the entries listed below; source area files are internal.
5136
5157
  | `DiscordCard` | `pi-roundtable/discord` | type |
5137
5158
  | `DiscordFailure` | `pi-roundtable/discord` | type |
5138
5159
  | `DiscordMessage` | `pi-roundtable/discord` | type |
5160
+ | `DiscordAgentGuild` | `pi-roundtable/discord` | type |
5161
+ | `DiscordAgentGuildOptions` | `pi-roundtable/discord` | type |
5139
5162
  | `DiscordPlaceProviderOptions` | `pi-roundtable/discord` | type |
5140
5163
  | `DiscordPoster` | `pi-roundtable/discord` | type |
5141
5164
  | `DiscordReason` | `pi-roundtable/discord` | type |
@@ -5164,6 +5187,7 @@ Import from the entries listed below; source area files are internal.
5164
5187
  | `commandGuard` | `pi-roundtable/discord` | value |
5165
5188
  | `composeCommands` | `pi-roundtable/discord` | value |
5166
5189
  | `discord` | `pi-roundtable/discord` | value |
5190
+ | `discordAgentGuild` | `pi-roundtable/discord` | value |
5167
5191
  | `discordPlaceProvider` | `pi-roundtable/discord` | value |
5168
5192
  | `ephemeralPanel` | `pi-roundtable/discord` | value |
5169
5193
  | `fetchManagedChannel` | `pi-roundtable/discord` | value |
@@ -5185,6 +5209,7 @@ Import from the entries listed below; source area files are internal.
5185
5209
  | `CharacterError` | `pi-roundtable/characters` | value |
5186
5210
  | `EAST_ASIAN_SKINS` | `pi-roundtable/characters` | value |
5187
5211
  | `EXPRESSIONS` | `pi-roundtable/characters` | value |
5212
+ | `PIVOTS` | `pi-roundtable/characters` | value |
5188
5213
  | `STATE_EXPRESSION` | `pi-roundtable/characters` | value |
5189
5214
  | `accentOf` | `pi-roundtable/characters` | value |
5190
5215
  | `characterCss` | `pi-roundtable/characters` | value |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-roundtable",
3
- "version": "0.45.1",
3
+ "version": "0.46.0",
4
4
  "description": "A plugin-driven Pi agent server for one owner, reached through Discord or the web",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -148,9 +148,10 @@ function tonesOf(
148
148
  };
149
149
  }
150
150
 
151
- function group(name: string, inner: string, extra = ""): string {
151
+ /** `follows` adds a class the stylesheet moves with: `hd` on every part that turns about the neck. */
152
+ function group(name: string, inner: string, extra = "", follows = ""): string {
152
153
  return inner
153
- ? `<g class="${name}" data-part="${name}"${extra}>${inner}</g>`
154
+ ? `<g class="${name}${follows}" data-part="${name}"${extra}>${inner}</g>`
154
155
  : "";
155
156
  }
156
157
 
@@ -258,8 +259,10 @@ export function composeSvg(
258
259
  const inner =
259
260
  (bare ? "" : group("frame", frameMarkup)) +
260
261
  `<g class="ch">` +
261
- group("back", hair.back + hood) +
262
+ group("back", hair.back + hood, "", " hd") +
262
263
  group("body", body) +
264
+ // The head's parts are one group, so the page can turn the head about the neck (`PIVOTS.neck`).
265
+ `<g class="hd" data-part="headset">` +
263
266
  group("head", head) +
264
267
  group("hat", HATS[s.hat](tones)) +
265
268
  group("eyes-brows", face.eyes + face.brows) +
@@ -269,6 +272,7 @@ export function composeSvg(
269
272
  "acc",
270
273
  s.accessory === "none" ? "" : ACCESSORIES[s.accessory](tones),
271
274
  ) +
275
+ `</g>` +
272
276
  group("prop", PROPS[s.prop](tones), ` data-prop="${s.prop}"`) +
273
277
  `</g>` +
274
278
  group(
@@ -22,6 +22,7 @@ export type { CharacterLook, ComposeOptions } from "./compose.ts";
22
22
  export { accentOf, composeSvg } from "./compose.ts";
23
23
  export { characterCss } from "./css.ts";
24
24
  export { parseCharacter, readCharacter } from "./parse.ts";
25
+ export { PIVOTS } from "./parts-face.ts";
25
26
  export { checkSkins, EAST_ASIAN_SKINS } from "./skins.ts";
26
27
  export type {
27
28
  CharacterColors,
@@ -190,12 +190,15 @@ const OVERLAY = {
190
190
  zz: [73, 28] as const,
191
191
  };
192
192
 
193
- /** Where the animation turns each part; characters.css carries them. */
193
+ /** Where the animation turns each part; characters.css carries them, and the page's own stylesheets the neck. */
194
194
  export const PIVOTS = {
195
195
  eyes: `50px ${FACE.ey}px`,
196
196
  badge: `${OVERLAY.badge[0]}px ${OVERLAY.badge[1]}px`,
197
197
  orbit: `${OVERLAY.orbit[0]}px ${OVERLAY.orbit[1]}px`,
198
198
  character: "50px 94px",
199
+ // Under the chin (the head ends at y 77) and over the torso (it starts at y 71), so a turn up to
200
+ // about 8° leaves no gap. The page's stylesheet for the head group (`.hd`) turns about it.
201
+ neck: "50px 76px",
199
202
  } as const;
200
203
 
201
204
  export const INK = "#2b2440";
@@ -22,7 +22,7 @@ import { answersAuthor } from "../routing/peer-bots.ts";
22
22
  import { outcome } from "../routing/settle-turn.ts";
23
23
  import { systemTurn } from "../routing/system-turns.ts";
24
24
  import { PERSONAL_TARGET } from "../shared/personal-target.ts";
25
- import type { DiscordAgentTeam } from "./agent-team.ts";
25
+ import type { AgentServerTeam } from "./agent-team.ts";
26
26
 
27
27
  /**
28
28
  * The agent server outranks every other claim on the places it owns, and the other channels of a
@@ -56,7 +56,7 @@ export interface AgentClaimOptions {
56
56
  */
57
57
  spaceOf?: (channel: ChannelKey) => string | undefined;
58
58
  team: Pick<
59
- DiscordAgentTeam,
59
+ AgentServerTeam,
60
60
  | "owns"
61
61
  | "answerOwner"
62
62
  | "answerGroup"
@@ -1,13 +1,18 @@
1
1
  import type { SQL } from "bun";
2
+ import {
3
+ LEGACY_CHANNEL_SURFACE,
4
+ setLegacyChannel,
5
+ } from "../db/legacy-channels.ts";
2
6
  import { AgentError } from "../domain/errors.ts";
3
7
  import { AgentBook } from "./agent-book.ts";
4
- import type { AgentPlaces } from "./agent-places.ts";
8
+ import type { AgentPlaces, PlaceOwnerKind } from "./agent-places.ts";
5
9
  import {
6
10
  type AgentGroup,
7
11
  type Backlog,
8
12
  checkDisplayName,
9
13
  type GroupMessage,
10
14
  } from "./agent-rules.ts";
15
+ import type { AgentRow, GroupRow } from "./agent-schema.ts";
11
16
  import { AgentStatements } from "./agent-statements.ts";
12
17
  import { GroupMessages } from "./group-messages.ts";
13
18
 
@@ -45,6 +50,74 @@ export abstract class AgentGroupStore extends AgentBook {
45
50
  return run;
46
51
  }
47
52
 
53
+ /**
54
+ * Records the place an agent or group has on a surface, in place of the one it had there. Until
55
+ * 1.0 the place of the surface the legacy `channel_id` columns hold is written to its column as
56
+ * well, in the same transaction.
57
+ */
58
+ async setPlace(
59
+ kind: PlaceOwnerKind,
60
+ name: string,
61
+ surface: string,
62
+ id: string,
63
+ ): Promise<void> {
64
+ return this.#writePlace(kind, name, surface, id);
65
+ }
66
+
67
+ /** Forgets the place an agent or group has on a surface; the place itself stays where it is. */
68
+ async clearPlace(
69
+ kind: PlaceOwnerKind,
70
+ name: string,
71
+ surface: string,
72
+ ): Promise<void> {
73
+ return this.#writePlace(kind, name, surface, null);
74
+ }
75
+
76
+ #writePlace(
77
+ kind: PlaceOwnerKind,
78
+ name: string,
79
+ surface: string,
80
+ id: string | null,
81
+ ): Promise<void> {
82
+ return this.serial(async () => {
83
+ const known =
84
+ kind === "agent" ? this.agentMap.has(name) : this.groupMap.has(name);
85
+ if (!known) throw new AgentError(`There is no ${kind} "${name}".`);
86
+ if (surface !== LEGACY_CHANNEL_SURFACE) {
87
+ if (id === null) await this.places.unbind(kind, name, surface);
88
+ else await this.places.bind(kind, name, surface, id);
89
+ return;
90
+ }
91
+ if (kind === "agent") {
92
+ const rows = await this.places.legacy(
93
+ "agent",
94
+ async (tx) =>
95
+ (await setLegacyChannel(
96
+ tx,
97
+ kind,
98
+ this.teamId,
99
+ name,
100
+ id,
101
+ )) as AgentRow[],
102
+ );
103
+ this.keepAgent(rows[0]);
104
+ } else {
105
+ const rows = await this.places.legacy(
106
+ "group",
107
+ async (tx) =>
108
+ (await setLegacyChannel(
109
+ tx,
110
+ kind,
111
+ this.teamId,
112
+ name,
113
+ id,
114
+ )) as GroupRow[],
115
+ );
116
+ this.keepGroup(rows[0]);
117
+ }
118
+ });
119
+ }
120
+
48
121
  async createGroup(group: {
49
122
  name: string;
50
123
  displayName: string;
@@ -119,6 +119,38 @@ export class AgentPlaces {
119
119
  return rows;
120
120
  }
121
121
 
122
+ /**
123
+ * Records the owner's place on a surface the legacy columns do not hold, in place of the one it
124
+ * had there. A place id belongs to one owner: another owner's holding it fails the write.
125
+ */
126
+ async bind(
127
+ kind: PlaceOwnerKind,
128
+ name: string,
129
+ surface: string,
130
+ externalId: string,
131
+ ): Promise<void> {
132
+ await this.#sql`
133
+ INSERT INTO agent_places (team_id, kind, name, surface, external_id)
134
+ VALUES (${this.#team}, ${kind}, ${name}, ${surface}, ${externalId})
135
+ ON CONFLICT (team_id, kind, name, surface)
136
+ DO UPDATE SET external_id = EXCLUDED.external_id`;
137
+ this.#replace({ kind, name, surface, externalId });
138
+ }
139
+
140
+ /** Forgets the owner's place on a surface the legacy columns do not hold. */
141
+ async unbind(
142
+ kind: PlaceOwnerKind,
143
+ name: string,
144
+ surface: string,
145
+ ): Promise<void> {
146
+ await this.#sql`
147
+ DELETE FROM agent_places
148
+ WHERE team_id = ${this.#team} AND kind = ${kind} AND name = ${name}
149
+ AND surface = ${surface}`;
150
+ const place = this.#byOwner.get(ownerKey(kind, name, surface));
151
+ if (place) this.#forget(place);
152
+ }
153
+
122
154
  /** Runs a write that deletes the owner's rows and, in the same transaction, every place it had. */
123
155
  async dropping(
124
156
  kind: PlaceOwnerKind,
@@ -1,6 +1,4 @@
1
1
  import type { AgentRuntime, ContextUse } from "../contract/runtime.ts";
2
- import type { IntercomCard } from "../domain/conversation.ts";
3
- import type { InterimPosts } from "../domain/interim.ts";
4
2
  import type { ThinkingSetting } from "../domain/models.ts";
5
3
 
6
4
  export type { ContextUse };
@@ -15,98 +13,6 @@ export type AgentTurnRunner = Pick<
15
13
  | "contextUsage"
16
14
  >;
17
15
 
18
- /** One agent's message in a channel, posted under its name and avatar. */
19
- export interface AgentPost {
20
- name: string;
21
- avatarUrl: string;
22
- /** The turn's thinking, posted first as a quiet line. */
23
- thinking?: string;
24
- chunks: string[];
25
- files?: { name: string; data: Uint8Array }[];
26
- /** A thread of the channel to post in instead, such as a dispatch's. */
27
- threadId?: string;
28
- /** A message between agents, shown as a small card in place of `chunks` where the channel can. */
29
- intercom?: IntercomCard;
30
- }
31
-
32
- /**
33
- * A category's name. Agents live under `Agents` or `Agents-<suffix>`, groups under `Groups` or
34
- * `Groups-<suffix>`, and archived ones, kept with their history, under `Archive`.
35
- */
36
- export type AgentCategory = string;
37
-
38
- /** A category of the agent server and its channels, in server order. */
39
- export interface CategoryLayout {
40
- /** Absent for a category still to be made. */
41
- id?: string;
42
- name: string;
43
- channelIds: string[];
44
- }
45
-
46
- /** A message of the agent server as `channel_read` returns it. */
47
- export interface ChannelMessage {
48
- id: string;
49
- author: string;
50
- at: Date;
51
- text: string;
52
- attachments: string[];
53
- }
54
-
55
- /** The agent server's channels as the agent team needs them. */
56
- export interface AgentChannels {
57
- post(channelId: string, post: AgentPost): Promise<void>;
58
- /**
59
- * Where a running turn posts the text it writes before its final answer, under the same name
60
- * and avatar as `post`; absent = only the final reply is posted.
61
- */
62
- interim?(
63
- channelId: string,
64
- as: Omit<AgentPost, "thinking" | "chunks" | "files">,
65
- ): InterimPosts;
66
- /** Creates a text channel under the category, made when missing; returns its id. */
67
- createChannel(
68
- name: string,
69
- topic: string,
70
- category: AgentCategory,
71
- ): Promise<string>;
72
- /**
73
- * Opens a thread under a channel to be a temp knight's place, with no start message; returns its
74
- * id. Posts to that id speak through the parent channel's webhook into the thread. Absent: a
75
- * temp knight lives in rooms only.
76
- */
77
- createThread?(parentChannelId: string, name: string): Promise<string>;
78
- /** Archives and locks a temp knight's thread (locked only when permitted); its history stays. */
79
- closeThread?(threadId: string): Promise<void>;
80
- /** Opens a temp knight's archived thread again, unlocked. */
81
- openThread?(threadId: string): Promise<void>;
82
- /** Moves a channel into the category when it sits elsewhere; true when it moved. */
83
- placeIn(channelId: string, category: AgentCategory): Promise<boolean>;
84
- /** Every category of the server in order, each with its channels in order. */
85
- layout(): Promise<CategoryLayout[]>;
86
- /**
87
- * Puts the categories, and the channels in each, in this order, making categories without an
88
- * id; then deletes the categories of `remove` that hold no channel.
89
- */
90
- arrange(layout: CategoryLayout[], remove: string[]): Promise<void>;
91
- setTopic(channelId: string, topic: string): Promise<void>;
92
- /** Deletes the assistant's webhook in the channel, when it has one; its past messages stay. */
93
- removeWebhook(channelId: string): Promise<void>;
94
- exists(channelId: string): Promise<boolean>;
95
- /**
96
- * Up to `limit` messages of a text channel or thread of the agent server, oldest first: the
97
- * latest, or those around `around`. Other servers' channels are refused.
98
- */
99
- read(
100
- channelId: string,
101
- options: { limit: number; around?: string },
102
- ): Promise<ChannelMessage[]>;
103
- }
104
-
105
- /** The dashboard channel's one pinned message, made when missing and edited in place. */
106
- export interface DashboardBoard {
107
- show(sections: string[]): Promise<void>;
108
- }
109
-
110
16
  /** The models an agent can run on, and the assistant's own, which unset agents follow. */
111
17
  export interface AgentModels {
112
18
  /** The assistant's thinking is `auto`: the judge picks each turn's level. */
@@ -1,4 +1,5 @@
1
1
  import { parseChannelKey, type SurfacePort } from "../contract/surface.ts";
2
+ import { LEGACY_CHANNEL_SURFACE } from "../db/legacy-channels.ts";
2
3
  import type { ChannelKey } from "../domain/conversation.ts";
3
4
  import { messages } from "../i18n/index.ts";
4
5
  import { type OwnerIdentity, ownerWords } from "../identity/owner-identity.ts";
@@ -201,7 +202,8 @@ export function placeOf(
201
202
  ): { surface: { label: string; key: string; others: readonly string[] } } {
202
203
  const prefix = parseChannelKey(home).surface;
203
204
  const label = (name: string) =>
204
- surfaces?.of(`${name}:`)?.label ?? (name === "discord" ? "Discord" : name);
205
+ surfaces?.of(`${name}:`)?.label ??
206
+ (name === LEGACY_CHANNEL_SURFACE ? "Discord" : name);
205
207
  const names = holders.filter(
206
208
  (n, i, all) => n !== prefix && all.indexOf(n) === i,
207
209
  );