pi-roundtable 0.42.0 → 0.44.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 (41) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +1 -0
  3. package/README.zh-TW.md +1 -0
  4. package/docs/plugins.md +3 -1
  5. package/package.json +3 -1
  6. package/src/characters/catalog.ts +7 -750
  7. package/src/characters/class-data.ts +56 -0
  8. package/src/characters/classes-a.ts +235 -0
  9. package/src/characters/classes-b.ts +242 -0
  10. package/src/characters/classes-c.ts +241 -0
  11. package/src/core/agents/agent-claim.ts +6 -2
  12. package/src/core/agents/agent-group-store.ts +176 -0
  13. package/src/core/agents/agent-places.ts +197 -0
  14. package/src/core/agents/agent-schema.ts +37 -3
  15. package/src/core/agents/agent-statements.ts +14 -12
  16. package/src/core/agents/agent-store.ts +81 -211
  17. package/src/core/agents/agent-team-fixture.ts +9 -3
  18. package/src/core/agents/agent-team.ts +6 -8
  19. package/src/core/agents/routes.ts +24 -7
  20. package/src/core/agents/team-options.ts +2 -0
  21. package/src/core/builtin/agent-server-options.ts +101 -0
  22. package/src/core/builtin/agent-server.ts +35 -94
  23. package/src/core/config/config-schema.ts +3 -1
  24. package/src/core/config/config.ts +5 -0
  25. package/src/core/config/team.ts +30 -0
  26. package/src/core/contract/channels.ts +8 -0
  27. package/src/core/db/legacy-channels.ts +92 -0
  28. package/src/core/db/team-move.ts +138 -0
  29. package/src/core/host/define-roundtable.ts +10 -2
  30. package/src/core/host/drain.ts +46 -0
  31. package/src/core/host/host.ts +25 -8
  32. package/src/core/plugin-api/plugin.ts +6 -3
  33. package/src/core/plugin-api/services.ts +4 -5
  34. package/src/core/presentation/diagram-text.ts +17 -8
  35. package/src/core/routing/channel-queue.ts +36 -3
  36. package/src/core/testing/fake-discord.ts +67 -0
  37. package/src/core/testing/partial.ts +8 -0
  38. package/src/core/testing/plugin-stand-ins.ts +95 -0
  39. package/src/core/testing/service-pair.ts +18 -0
  40. package/src/core/testing/test-plugin-types.ts +110 -0
  41. package/src/testing.ts +36 -276
package/CHANGELOG.md CHANGED
@@ -5,6 +5,41 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.44.0] - 2026-11-09
9
+
10
+ ### Added
11
+
12
+ - The agent server keeps a new table, `agent_places`, with one row per agent or group per surface that holds its place (`team_id`, `kind`, `name`, `surface`, `external_id`). Two migrations come with it: `agent-server/agent-places` creates the table once, and `agent-server/agent-places-from-channels` runs at every boot and makes the Discord rows equal the `agents.channel_id` and `agent_groups.channel_id` columns, so a rollback to an older build, which writes only the columns, converges at the next boot. The store writes the row and the column in one transaction; nothing reads the table yet, and keys, tools and text are unchanged.
13
+ - A team that was stored under a former id (`formerIds`) has its place rows moved with the rest of its rows, and a team that left its Discord guild loses the rows of the Discord places it left, as it loses their channel ids. A row that stays under the former id, because the team holds its key or its place id already, is named in a warning at boot. Each boot converges the place rows of its own team only, so hosts of several teams over one database leave each other's rows alone.
14
+
15
+ ### Fixed
16
+
17
+ - pi-roundtable-coding: Two coding workers that start at once on one repository no longer fail now and then with `fatal: failed to read .git/worktrees/1/commondir`, which ended one of the tasks before its worker ran. Git lists every linked worktree while it adds, removes or prunes one and fails on a folder another such call is still writing, so the desk now makes, removes and prunes the worktrees of one clone one at a time.
18
+
19
+ ## [0.43.0] - 2026-11-09
20
+
21
+ ### Added
22
+
23
+ - pi-roundtable-mcp: `ConnectorRegistry.resync(name)` and `resyncAll()`, on `CONNECTORS` as `resync(name)` and `resyncAll()` and on Discord as `/<root> connector resync [name]`. A resync has the gateway read the connector's upstream server again, then sets its virtual server's tools to the gateway's current ones (names longer than `maxToolName` are skipped and reported as at add) and reads their hints, so an upstream that renamed tools is picked up, each renamed tool with the hints its upstream gives it, without removing the connector and entering its token again. A tool that keeps its name keeps the hints the gateway first stored for it, because the gateway's refresh does not update them: for hints that changed upstream under the same name, remove and add the connector again, or set the hints on the gateway. The gateway, the virtual server, the token, the purpose and the stored row stay; `version` changes when the tools or their hints did. Resyncs run one at a time.
24
+ - pi-roundtable-mcp: A failure before the gateway reads the upstream leaves the connector as it was. The gateway's own refresh drops the tools the upstream no longer offers from the virtual server, so a failure after it (the upstream offers no usable tool, or a later request fails) may leave the virtual server with fewer tools until the next resync; it is logged as such. Until the new tools are read back, the connector lists both the old and the new tool names with their hints, so the `mcp-hints` rule holds a renamed destructive tool even when the read-back fails.
25
+ - pi-roundtable-mcp: A resync makes five admin requests per connector and spaces them by `resyncIntervalMs` (default 1200, 50 a minute, half of the gateway's limit of 100 a minute, which locks the admin account for 15 minutes when exceeded; 0 turns pacing off). When the gateway answers 429, or 401, 403 or 423 (the account refused or locked), `resyncAll` stops there without retrying: the connector that met it and the ones after it are reported as not resynced, a single `resync` fails with `ConnectorRateLimited`, and every resync is refused without a request for `resyncLockoutMs` (default 15 minutes).
26
+ - pi-roundtable-mcp: The gateway's admin client gains `refreshGateway` and `setServerTools`, its tool type optional `gatewayId` and `hints`, its error type an optional `status`, and `ConnectorMessages` the keys `resyncDescription`, `resyncNameOption`, `resyncedTitle`, `resyncedAllTitle`, `resyncedFooter`, `resyncChanges`, `resyncUnchanged`, `resyncFailed`, `resyncNotAttempted` and the gateway's refresh-failure message. `ConnectorRateLimited` is exported.
27
+ - pi-roundtable-mcp: **Breaking for hosts that implement `Connectors`:** the type gains `resync` and `resyncAll`, which such a host needs to provide.
28
+ - pi-roundtable-mcp: `mcpConnectors` resyncs every stored connector in its preflight, after loading them, at that pace. A failure is logged. The `listFooter` text mentions `resync`.
29
+ - pi-roundtable-coding, pi-roundtable-drawing: `pi-roundtable-coding` exports `DEFAULT_TOOL_TEXT`, the shipped description and argument text of every repository tool, so a host sets `toolText` for only the wording that differs and sees what an upgrade changed. The `presentation` hooks `list`, `changeReport`, `taskStarted` and `taskQueued` now receive the package's own text as a last argument, so a host can append to it instead of replacing it.
30
+ - pi-roundtable-coding, pi-roundtable-drawing: `pi-roundtable-drawing` takes a `toolText` option, the same for its five tools, and exports `DEFAULT_DRAWING_TOOL_TEXT`; unset text keeps the package wording, and a tool or argument the plugin does not have stops the start.
31
+ - `team.id` gives the team the id its rows are stored under, independent of `discord.guild` (default the guild's id, else `local`), and `team.formerIds` lists the ids it was stored under before: their rows move to the team's id at every boot, and a team without Discord channels loses the channel ids they carried. `AgentTeam.discordGuild` names the guild the team's channels live in, which the web console links by.
32
+
33
+ ### Fixed
34
+
35
+ - A deploy no longer cuts a coding worker short without a word. The shutdown drain (`drainSeconds`, now up to 14,400) waits for the desk's running workers and for reports still being delivered. A service can now tell the drain began (`Service.beginDrain()`): the coding desk then starts no queued task, reports each as "not started: host restarting, dispatch again after restart", and refuses `repo_task` with the same message. At the limit the drain calls the new `Service.abort()` before `stop()`, and the desk stops each worker with SIGTERM (the worker saves its tracked changes in a `wip:` commit, `stopGraceMs` of 5 seconds before SIGKILL), keeps its branch and worktree unmerged, and reports where they are.
36
+ - A coding worker that is cancelled or runs out of time is killed at once and its branch is never merged into the clone, even when its worktree is clean; the report names the kept branch and worktree. Only a host shutdown saves a `wip:` commit. `CodingDesk.stop()` stops workers the same way and waits at most `stopWaitMs` (15 seconds) for reports.
37
+ - New `QueuePort.finishing(task)` (absent on an older host): a queue task started inside it, and what it awaits, is admitted although the host is shutting down, until the drain ends. The coding plugin delivers every report through it, so the report of a worker that ends during the drain is no longer refused with "the host is shutting down". After the abort grace the host tells the turns still running in the queue to stop once more, so a report turn begun during the grace cannot run past the drain.
38
+ - A coding worker that gets SIGTERM from outside the desk (a `systemctl kill`, a cgroup-wide stop, a manual `kill`) still saves its `wip:` commit but now reports a `stopped` failure; the desk refuses to merge that run, keeps its branch and worktree, and says so in the report. A run that already timed out is reported as timed out even when `interrupt()` or `stop()` lands afterwards.
39
+ - A team that moves between Discord guilds clears the channel ids of the rows from any former id that is not its current guild, so start creates fresh channels instead of archiving the team. Two former ids that hold the same key no longer fail every boot: the one listed first moves, and a warning names the rows that stay behind. A team without Discord channels also clears the channel ids its own rows hold. `testPlugin` gives the agent claim the team's Discord guild again.
40
+ - A team without Discord channels ignores a channel id still stored on an agent or group: its primary place is its room, and a notice or report no longer goes to a deleted channel.
41
+ - pi-roundtable-web: A device that was refused an answer as `answered` no longer keeps its own lock on the block: the server's record decides, so when the first device's send fails and the row comes back without the answer, the page opens the block again too (0.42.0 said so, but only the server half was in).
42
+
8
43
  ## [0.42.0] - 2026-11-08
9
44
 
10
45
  ### Added
package/README.md CHANGED
@@ -202,6 +202,7 @@ Without `discord`, or with `discord` but no `discord.guild`, the agents still ru
202
202
  | `discord.guild` | none | The agent server's guild, where the agents' channels, categories and `#dashboard` live; needs `discord.entryChannel` and `http.publicUrl`. Left out, the bot keeps serving the plugins' claims, slash commands and the owner's direct messages in every guild it is in, and the team lives in the app's rooms as without `discord`: `agents` is required and `entryChannel` is an error |
203
203
  | `agents` | none | The first team, created once. Without `discord.guild`, a seed has no `channelId` and the team's rows are kept under the id `local` |
204
204
  | `coordinator` | the first of `agents` | Without `discord.guild`, the agent the owner's general requests come to; it cannot be archived. With `discord.guild` it is an error: the entry channel's agent coordinates |
205
+ | `team.id`, `team.formerIds` | the `discord.guild` id, else `local`; none | The id the team's rows are stored under, independent of the guild, and the ids it was stored under before: their rows move to it at every boot, and without Discord channels lose their channel ids |
205
206
  | `skills` | on with `agents` | The skills addon; without `discord` it is on only when `agents` lists some |
206
207
  | `helpers` | 4 per knight, 12 in all, archived 24 hours after finishing | Temp knights, the helpers a knight makes with `helper_create` for one task and clears with `helper_end`: `{ perParent, perHost, archiveFinishedAfterHours }`; `false` offers neither tool |
207
208
 
package/README.zh-TW.md CHANGED
@@ -197,6 +197,7 @@ export default {
197
197
  | `discord.guild` | 無 | agent server 的伺服器,agent 的頻道、分類與 `#dashboard` 都在這裡;需要 `discord.entryChannel` 與 `http.publicUrl`。不設時,bot 仍在它加入的每個伺服器服務外掛的 claim、斜線指令與主人的私訊,團隊則像沒有 `discord` 時一樣住在 app 的房間:必須設 `agents`,設 `entryChannel` 會出錯 |
198
198
  | `agents` | 無 | 第一批團隊,只建立一次。沒有 `discord.guild` 時,種子沒有 `channelId`,團隊的資料列記在 id `local` 之下 |
199
199
  | `coordinator` | `agents` 的第一位 | 沒有 `discord.guild` 時,接手主人一般請求的 agent,不能被封存。有 `discord.guild` 時設它會出錯:由入口頻道的 agent 協調 |
200
+ | `team.id`、`team.formerIds` | `discord.guild` 的 id,否則 `local`;無 | 團隊資料列存放用的 id(與 guild 無關),以及先前用過的 id:其資料列每次啟動時搬到新 id,沒有 Discord 頻道時一併清掉頻道 id |
200
201
  | `skills` | 有 `agents` 時開啟 | 技能 addon;沒有 `discord` 時,只有 `agents` 列了 agent 才會開 |
201
202
  | `helpers` | 每位騎士 4 位、全站 12 位,結束 24 小時後封存 | 臨時騎士:騎士用 `helper_create` 為單一任務做出、完成後用 `helper_end` 清掉的幫手。設定為 `{ perParent, perHost, archiveFinishedAfterHours }`;`false` 兩個工具都不提供 |
202
203
 
package/docs/plugins.md CHANGED
@@ -1443,6 +1443,8 @@ test("the handlers record a turn, a team change, and the shutdown", async () =>
1443
1443
  A service has a name and optional `start`, `stop`, and `busy`.
1444
1444
  Services start once everything is set up and stop in reverse order.
1445
1445
  `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.
1446
+ `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.
1447
+ `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.
1446
1448
  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.
1447
1449
 
1448
1450
  A service may also have `startInBackground`.
@@ -4254,7 +4256,7 @@ The same host may call `run()` again after that.
4254
4256
  On `SIGTERM` or `SIGINT` the bot takes no new work at once, finishes what runs, and stops serving last:
4255
4257
 
4256
4258
  1. It stops starting work: the channel queue closes (`context.queue.closed` turns true), and from then on no new turn starts, whoever asks. A message that arrives is not run; its channel gets one short "restarting, try again shortly" reply, except a bot's or an integration's message, which is only logged. A background turn (a schedule's, a delegated task's report, an error report) is skipped, and so is a turn a plugin asks of `context.turns.run`, which rejects with `HostStoppingError`; a task for the queue that has not started, whether queued before or after, is refused with the same error. The scheduler claims nothing, so a due schedule stays due and fires after the next start if it is less than twelve hours late. A turn that is already running finishes. A plugin that starts turns from a timer or a route of its own should check `context.queue.closed` first.
4257
- 2. It waits until the channel queue is empty and no service reports `busy()` work, for at most three minutes (`drainSeconds` in the config, `drain.limitMs` in `RoundtableOptions`). If work is left, it stops each running turn as the owner's stop does, gives them ten seconds (`drain.abortGraceMs`) to end, and goes on; whatever is left is logged and given up on.
4259
+ 2. It waits until the channel queue is empty and no service reports `busy()` work, for at most three minutes by default (`drainSeconds` in the config, up to 14,400, that is four hours; `drain.limitMs` in `RoundtableOptions`). If work is left, it stops each running turn as the owner's stop does and calls `abort()` of each service that still has work, gives them ten seconds (`drain.abortGraceMs`) to end, and goes on; whatever is left is logged and given up on, and a turn still running in the queue after the grace is told to stop once more. Work that ends during the wait delivers its report through `context.queue.finishing`, which the queue admits until the wait is over; the queue is sealed after it.
4258
4260
  3. Every plugin hears `shutdown(left)`, while every service is still running.
4259
4261
  4. The HTTP listener closes, so no request reaches a service that has stopped.
4260
4262
  5. Services stop in the reverse of the order they started.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-roundtable",
3
- "version": "0.42.0",
3
+ "version": "0.44.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",
@@ -34,6 +34,8 @@
34
34
  "!src/core/discord/poster/poster-contract*.ts",
35
35
  "!src/core/testing/fixtures",
36
36
  "!src/characters/fixtures",
37
+ "!src/m2-acceptance",
38
+ "!src/fixtures",
37
39
  "!src/prompt-text.snapshot.json",
38
40
  "!src/cli/testing",
39
41
  "templates",