pi-roundtable 0.40.0 → 0.43.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.
- package/CHANGELOG.md +53 -0
- package/README.md +6 -4
- package/README.zh-TW.md +6 -4
- package/docs/plugins.md +32 -5
- package/package.json +2 -2
- package/src/core/agents/agent-claim.ts +6 -2
- package/src/core/agents/agent-team-fixture.ts +9 -3
- package/src/core/agents/agent-team.ts +7 -8
- package/src/core/agents/agent-tools.ts +12 -4
- package/src/core/agents/routes.ts +24 -7
- package/src/core/agents/team-options.ts +2 -0
- package/src/core/builtin/agent-server-options.ts +101 -0
- package/src/core/builtin/agent-server.ts +34 -100
- package/src/core/config/adapters.ts +13 -7
- package/src/core/config/agent-team.ts +45 -4
- package/src/core/config/config-schema.ts +3 -1
- package/src/core/config/config.ts +23 -23
- package/src/core/config/ops.ts +1 -1
- package/src/core/config/routing.ts +3 -3
- package/src/core/config/team.ts +30 -0
- package/src/core/contract/channels.ts +8 -0
- package/src/core/db/team-move.ts +103 -0
- package/src/core/host/define-roundtable.ts +15 -5
- package/src/core/host/drain.ts +46 -0
- package/src/core/host/host-registration.ts +5 -0
- package/src/core/host/host.ts +31 -8
- package/src/core/plugin-api/holds.ts +31 -0
- package/src/core/plugin-api/plugin.ts +6 -3
- package/src/core/plugin-api/services.ts +4 -5
- package/src/core/presentation/diagram-text.ts +17 -8
- package/src/core/routing/channel-queue.ts +36 -3
- package/src/core/runtime/extensions/yolo.ts +3 -0
- package/src/core/runtime/mcp.ts +10 -0
- package/src/core/testing/partial.ts +8 -0
- package/src/kit/holds.ts +1 -0
- package/src/kit/index.ts +6 -1
- package/src/kit/worker.ts +1 -1
- package/src/testing.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,59 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.43.0] - 2026-11-09
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- 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.
|
|
13
|
+
- 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.
|
|
14
|
+
- 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).
|
|
15
|
+
- 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.
|
|
16
|
+
- pi-roundtable-mcp: **Breaking for hosts that implement `Connectors`:** the type gains `resync` and `resyncAll`, which such a host needs to provide.
|
|
17
|
+
- 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`.
|
|
18
|
+
- 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.
|
|
19
|
+
- 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.
|
|
20
|
+
- `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.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- 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.
|
|
25
|
+
- 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.
|
|
26
|
+
- 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.
|
|
27
|
+
- 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.
|
|
28
|
+
- 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.
|
|
29
|
+
- 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.
|
|
30
|
+
- 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).
|
|
31
|
+
|
|
32
|
+
## [0.42.0] - 2026-11-08
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- The `tree` display block (`pi-better-show` 0.4.0) is drawn: the web app shows it as a directory tree, Discord and LINE get its ASCII drawing, and the web app's formatting guide describes it.
|
|
37
|
+
- `HoldRule.yolo: "never"` marks a hold rule whose calls yolo mode never approves, whatever the configuration says: its calls carry the class `<rule>.yolo-never`, which the yolo approver always cards (`YOLO_NEVER_CLASS` in `pi-roundtable/kit` names the suffix, so a plugin with its own yolo check, such as `pi-roundtable-coding`, refuses it too), and the host refuses to start when `autonomy.yolo.allow` names the rule or one of its classes (`RoundtableOptions.autonomy`, which `defineRoundtable` fills from `autonomy`). An unattended turn still fails a held call closed.
|
|
38
|
+
- `VirtualServer.hints` (`McpToolHints` in `pi-roundtable/kit`) lists each tool's MCP safety hints (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) by tool name. It is optional; `mcpExtension` ignores it.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- `pi-better-show` is pinned to 0.4.0.
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- pi-roundtable-mcp: `mcpConnectors` and `remoteMcp` start on a host without Discord: neither requires `DISCORD` any more, both read it with `services.find`. Without Discord the connectors add no slash commands and keep `CONNECTORS` and its management; remote MCP adds no `/<root> mcp` commands and no `/mcp/discord/<token>` route, serves `/mcp/personal`, keeps channel grants stored but unused, and with no agent server runs its default turns on the core's runtime. With Discord nothing changes.
|
|
47
|
+
|
|
48
|
+
## [0.41.0] - 2026-11-08
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- A Discord bot whose agent team lives only in the app: leave `discord.guild` out and keep `agents`. Discord stays connected for the plugins' claims, the globally registered slash commands and the owner's direct messages, and the team runs as on a host without Discord: id `local`, rooms only, the coordinator `coordinator` names, no agent channels, categories, `#dashboard`, entry channel or agent threads, and no guild asked for on the agents' behalf. `discord.entryChannel` without `discord.guild` is a `ConfigError`, and so is leaving out both the guild and `agents` unless `agentServer: false`; `http.publicUrl` is required only with the guild.
|
|
53
|
+
- pi-roundtable-web: a Webhooks page (`#/webhooks`, under More) lists and manages every knight's incoming webhooks in one place, from the new owner route `GET api/webhooks`. Its pane is `webhooks`; a host with an explicit `panes` list adds it itself, as with `presets`.
|
|
54
|
+
- pi-roundtable-coding: a coding task can be cancelled. `repo_task_cancel { repo, id, reason? }` drops a queued task before it runs, or stops a running worker the way a timeout does, closing the held actions it waited on; the stopped worker's commits stay on its branch and worktree, not merged into the clone, and its report says "cancelled by <name>" and names both. `repo_task_list { repo? }` lists running and queued tasks. An agent sees and cancels its own tasks, an owner any. The Settings page "Coding workers" lists the tasks with an owner-only Cancel action. `CodingDesk.cancel(id, by)` answers a `CancelResult` and `CodingDesk.tasks()` lists the tasks; `REPO_TOOLS` and `RepoToolName` gain the two names, and the `repo_task` result mentions `repo_task_cancel`.
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
|
|
58
|
+
- `DiscordConfig.guild` and `ResolvedDiscord.guild` are optional, `agentServer: false` included.
|
|
59
|
+
- A team without Discord channels is no longer offered `channel_arrange` or `channel_read`, and its `agent_create` and `group_create` take no `category`; before, they were offered and refused.
|
|
60
|
+
|
|
8
61
|
## [0.40.0] - 2026-11-08
|
|
9
62
|
|
|
10
63
|
### Added
|
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ Bun loads `.env` by itself, and `.gitignore` keeps it out of Git.
|
|
|
50
50
|
| Variable | What it is |
|
|
51
51
|
| --- | --- |
|
|
52
52
|
| `DISCORD_TOKEN` | The bot's token, from the application's Bot page |
|
|
53
|
-
| `DISCORD_GUILD_ID`, `DISCORD_ENTRY_CHANNEL_ID` | The server and the channel where the coordinating agent lives (turn on Developer Mode, then right-click to copy ids) |
|
|
53
|
+
| `DISCORD_GUILD_ID`, `DISCORD_ENTRY_CHANNEL_ID` | The server and the channel where the coordinating agent lives (turn on Developer Mode, then right-click to copy ids); leave both out of the configuration to keep the agents in the app's rooms |
|
|
54
54
|
| `OWNER_ID`, `OWNER_NAME` | You: the one person who can change everything |
|
|
55
55
|
| `DATABASE_URL` | PostgreSQL; the default matches `docker-compose.yml` |
|
|
56
56
|
| `MODEL` | The agents' model, `<provider>/<id>` |
|
|
@@ -195,12 +195,14 @@ A turn works 10 minutes by default before it asks you whether to go on, and 30 m
|
|
|
195
195
|
| `autonomy.yolo.questionGraceSeconds` | `30` | In a yolo conversation, how long an `ask_user` card holds the turn, 5 to 600; unanswered, the turn goes on with its own best choice and the card stays open |
|
|
196
196
|
| `autonomy.yolo.timeoutCardSeconds` | `60` | In a yolo conversation, how long the timeout card waits, 10 to 3600; unanswered, the turn goes on as if you pressed Continue, up to `autonomy.longRunning.maxSeconds` |
|
|
197
197
|
|
|
198
|
-
Without `discord` the agents still run when `agents` lists them, in the rooms of a surface that hosts them, such as pi-roundtable-web; the host refuses to start when none does:
|
|
198
|
+
Without `discord`, or with `discord` but no `discord.guild`, the agents still run when `agents` lists them, in the rooms of a surface that hosts them, such as pi-roundtable-web; the host refuses to start when none does:
|
|
199
199
|
|
|
200
200
|
| Setting | Default | What it is |
|
|
201
201
|
| --- | --- | --- |
|
|
202
|
-
| `
|
|
203
|
-
| `
|
|
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
|
+
| `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
|
+
| `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 |
|
|
204
206
|
| `skills` | on with `agents` | The skills addon; without `discord` it is on only when `agents` lists some |
|
|
205
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 |
|
|
206
208
|
|
package/README.zh-TW.md
CHANGED
|
@@ -47,7 +47,7 @@ Bun 會自己讀 `.env`,`.gitignore` 也已經擋掉它。
|
|
|
47
47
|
| 變數 | 內容 |
|
|
48
48
|
| --- | --- |
|
|
49
49
|
| `DISCORD_TOKEN` | bot 的 token,在應用程式的 Bot 頁面取得 |
|
|
50
|
-
| `DISCORD_GUILD_ID`、`DISCORD_ENTRY_CHANNEL_ID` | 伺服器,以及負責統籌的智慧體所在的頻道(開啟開發者模式後,按右鍵複製 id
|
|
50
|
+
| `DISCORD_GUILD_ID`、`DISCORD_ENTRY_CHANNEL_ID` | 伺服器,以及負責統籌的智慧體所在的頻道(開啟開發者模式後,按右鍵複製 id);設定裡兩者都不寫,agent 就留在 app 的房間 |
|
|
51
51
|
| `OWNER_ID`、`OWNER_NAME` | 你自己:唯一能改動一切的人 |
|
|
52
52
|
| `DATABASE_URL` | PostgreSQL;預設值與 `docker-compose.yml` 一致 |
|
|
53
53
|
| `MODEL` | 智慧體使用的模型,格式為 `<provider>/<id>` |
|
|
@@ -190,12 +190,14 @@ export default {
|
|
|
190
190
|
| `autonomy.yolo.questionGraceSeconds` | `30` | yolo 對話裡,`ask_user` 卡片讓這一輪等多久,5 到 600;沒回答時,這一輪照它自己的最佳選擇繼續,卡片仍然開著 |
|
|
191
191
|
| `autonomy.yolo.timeoutCardSeconds` | `60` | yolo 對話裡,逾時卡片等多久,10 到 3600;沒回答時,這一輪就像按了「繼續」一樣接著做,最多到 `autonomy.longRunning.maxSeconds` |
|
|
192
192
|
|
|
193
|
-
沒有 `discord` 時,只要 `agents` 列了 agent,它們就在支援房間的 surface(例如 pi-roundtable-web)裡運作;沒有任何 surface 支援房間時 host 拒絕啟動:
|
|
193
|
+
沒有 `discord`,或有 `discord` 但沒有 `discord.guild` 時,只要 `agents` 列了 agent,它們就在支援房間的 surface(例如 pi-roundtable-web)裡運作;沒有任何 surface 支援房間時 host 拒絕啟動:
|
|
194
194
|
|
|
195
195
|
| 設定 | 預設 | 說明 |
|
|
196
196
|
| --- | --- | --- |
|
|
197
|
-
| `
|
|
198
|
-
| `
|
|
197
|
+
| `discord.guild` | 無 | agent server 的伺服器,agent 的頻道、分類與 `#dashboard` 都在這裡;需要 `discord.entryChannel` 與 `http.publicUrl`。不設時,bot 仍在它加入的每個伺服器服務外掛的 claim、斜線指令與主人的私訊,團隊則像沒有 `discord` 時一樣住在 app 的房間:必須設 `agents`,設 `entryChannel` 會出錯 |
|
|
198
|
+
| `agents` | 無 | 第一批團隊,只建立一次。沒有 `discord.guild` 時,種子沒有 `channelId`,團隊的資料列記在 id `local` 之下 |
|
|
199
|
+
| `coordinator` | `agents` 的第一位 | 沒有 `discord.guild` 時,接手主人一般請求的 agent,不能被封存。有 `discord.guild` 時設它會出錯:由入口頻道的 agent 協調 |
|
|
200
|
+
| `team.id`、`team.formerIds` | `discord.guild` 的 id,否則 `local`;無 | 團隊資料列存放用的 id(與 guild 無關),以及先前用過的 id:其資料列每次啟動時搬到新 id,沒有 Discord 頻道時一併清掉頻道 id |
|
|
199
201
|
| `skills` | 有 `agents` 時開啟 | 技能 addon;沒有 `discord` 時,只有 `agents` 列了 agent 才會開 |
|
|
200
202
|
| `helpers` | 每位騎士 4 位、全站 12 位,結束 24 小時後封存 | 臨時騎士:騎士用 `helper_create` 為單一任務做出、完成後用 `helper_end` 清掉的幫手。設定為 `{ perParent, perHost, archiveFinishedAfterHours }`;`false` 兩個工具都不提供 |
|
|
201
203
|
|
package/docs/plugins.md
CHANGED
|
@@ -1097,7 +1097,7 @@ defineTool({
|
|
|
1097
1097
|
|
|
1098
1098
|
#### Hold classes and yolo mode
|
|
1099
1099
|
|
|
1100
|
-
Every held call carries its **hold classes**: ids of the form `<rule>.<class>` that name why it is held. They are what yolo mode (below) judges, and they are recorded with the call as `HeldCall.holdClasses`, so they survive a restart. A rule reports them with `holdClasses(tool, input, context)`, which lists every reason the call is held, not only the first. **Report only classes that are safe to approve with no one looking: a rule that reports classes has opted its calls in to yolo mode**, which approves them unless the config cards them. A rule that reports none leaves its calls **unclassed**: they carry the rule's bare name (`mail` for a rule called `mail`) and yolo cards them, unless `autonomy.yolo.allow` lists that name. A tool's own `hold` is a rule named `tool:<name>`, so it is unclassed, and `autonomy.yolo.allow: ["tool:repo_push"]` approves a `repo_push` tool's calls. Every reported id must start with the rule's name and a dot; one that does not, such as another rule's id, leaves the call unclassed, as does a `holdClasses` that throws. A rule that stands for other rules' calls, as the one that holds saving a precheck script does, declares `relay: true` and may list their ids instead; its calls also carry `<rule>.relay`, so `autonomy.yolo.card: ["precheck-scripts"]` cards them. A rule name has no dot. The same holds for `HoldDescription.classes`, and a hold check built without `holdChain` has no classes: yolo cards its calls. A rule that describes a call in a turn may name the classes in the description instead: `{ text, classes: ["repo.push"] }` (`HoldDescription.classes`). When several rules hold one call, its classes are all of theirs, so one unclassed or carded rule cards it. `holdChain(rules)` reports them as `classesOf(tool, input, context)` and, with the description, as `inTurnWithClasses(...)` (`ClassedHold`), which also asks the rules after the first that holds the call; a hold check built without `holdChain` has none.
|
|
1100
|
+
Every held call carries its **hold classes**: ids of the form `<rule>.<class>` that name why it is held. They are what yolo mode (below) judges, and they are recorded with the call as `HeldCall.holdClasses`, so they survive a restart. A rule reports them with `holdClasses(tool, input, context)`, which lists every reason the call is held, not only the first. **Report only classes that are safe to approve with no one looking: a rule that reports classes has opted its calls in to yolo mode**, which approves them unless the config cards them. A rule that reports none leaves its calls **unclassed**: they carry the rule's bare name (`mail` for a rule called `mail`) and yolo cards them, unless `autonomy.yolo.allow` lists that name. A tool's own `hold` is a rule named `tool:<name>`, so it is unclassed, and `autonomy.yolo.allow: ["tool:repo_push"]` approves a `repo_push` tool's calls. Every reported id must start with the rule's name and a dot; one that does not, such as another rule's id, leaves the call unclassed, as does a `holdClasses` that throws. A rule that stands for other rules' calls, as the one that holds saving a precheck script does, declares `relay: true` and may list their ids instead; its calls also carry `<rule>.relay`, so `autonomy.yolo.card: ["precheck-scripts"]` cards them. A rule name has no dot. The same holds for `HoldDescription.classes`, and a hold check built without `holdChain` has no classes: yolo cards its calls. A rule that describes a call in a turn may name the classes in the description instead: `{ text, classes: ["repo.push"] }` (`HoldDescription.classes`). When several rules hold one call, its classes are all of theirs, so one unclassed or carded rule cards it. `holdChain(rules)` reports them as `classesOf(tool, input, context)` and, with the description, as `inTurnWithClasses(...)` (`ClassedHold`), which also asks the rules after the first that holds the call; a hold check built without `holdChain` has none. A rule declared `yolo: "never"` is one yolo mode never approves: its calls carry the class `<rule>.yolo-never` whatever it reports, which yolo always cards, and the host refuses to start when `autonomy.yolo.allow` names the rule or one of its classes (a turn nobody can answer still fails its held call closed). `mcp-connectors` holds a connector's tool through such a rule, `mcp-hints`, when its server's hints mark it `destructiveHint: true` or `readOnlyHint: false`; `VirtualServer.hints` carries the hints.
|
|
1101
1101
|
|
|
1102
1102
|
**Yolo mode.** In a conversation whose `yolo` mode an owner switched on ([`MODES`](#conversation-modes-modes)), the server decides a held call before any card opens, and approves it without one only when **all** of these hold at that moment:
|
|
1103
1103
|
|
|
@@ -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`.
|
|
@@ -3654,6 +3656,7 @@ What needs Discord is refused or left out rather than failing later:
|
|
|
3654
3656
|
- `notify` is not registered unless a plugin contributes a [direct channel](#directchannels-reaching-a-person-on-their-own), since there is nowhere to send a notice.
|
|
3655
3657
|
- `schedule_*` and `delegate_task` are registered only in a conversation whose claim takes background turns: their runs are turns of the [background target](#backgroundtargets-whose-turn-a-schedule-or-delegated-task-is) `PERSONAL_TARGET`, named `owner`, which the core contributes on every host. A conversation of a claim without `background` has neither; a no-surface conversation needs a registered private principal known to a direct channel, as [background targets](#backgroundtargets-whose-turn-a-schedule-or-delegated-task-is) describes.
|
|
3656
3658
|
- `roundtable doctor` skips the Discord checks.
|
|
3659
|
+
- pi-roundtable-mcp's `mcpConnectors` and `remoteMcp` add no slash commands, and `remoteMcp` serves `/mcp/personal` without the `/mcp/discord/<token>` channel tools.
|
|
3657
3660
|
|
|
3658
3661
|
Pi's runtime still needs the `compact_session` tool in every session, from the Pi package pi-self-compact: load it from a plugin with `piPackages: ["pi-self-compact"]`, as the `plugins/self-compact.ts` of a project `roundtable init` creates does, or the preflight stops the start and says so.
|
|
3659
3662
|
`roundtable init --adapter web` creates a host without Discord around the [web chat](#web-chat-pi-roundtable-webchat).
|
|
@@ -3663,16 +3666,38 @@ A host that keeps Discord may write it as an adapter instead, as [`adapters`](#a
|
|
|
3663
3666
|
|
|
3664
3667
|
`agents` and `skills` work without `discord`. The host then assembles the agent server and the skills addon whenever `agents` is not empty: the same team, with the same prompts, models, notes, schedules and skills, whose agents and groups have no Discord channel and are reached only through [rooms](#agent-rooms-on-any-surface) of a surface that declares `agentRooms: true`, such as `pi-roundtable-web`.
|
|
3665
3668
|
|
|
3666
|
-
- `coordinator` names the agent that coordinates the team; it must be one of `agents` and defaults to the first. With `discord` the agent in `discord.entryChannel` is the coordinator, and `coordinator` is a `ConfigError`. The coordinator cannot be archived. `AGENTS.team.coordinator()` answers with either.
|
|
3669
|
+
- `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.
|
|
3667
3670
|
- 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.
|
|
3668
3671
|
- 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.
|
|
3669
|
-
- No channel is made, checked or arranged, and the dashboard (a Discord message) does not exist. `channel_arrange` and `channel_read` 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.
|
|
3670
|
-
- `category` on `agent_create` and `group_create
|
|
3672
|
+
- 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.
|
|
3673
|
+
- `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.
|
|
3671
3674
|
- 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.
|
|
3672
3675
|
- `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.
|
|
3673
3676
|
- A surface that lets the owner edit the team uses the same operations the agent tools do, from outside any agent turn: `AgentTeam.createAgent(speaker, input)` (the fields of `agent_create`, plus `model` and `thinking`, which are checked before anything is made; without a `task` the agent only exists, and `openIn` names the surface whose room runs the opening task instead of the Discord channel), `archive(undefined, name)` (an owner has no calling agent, so only the coordinator is protected), `restore(name)`, `remove(name, cleanup?)` (an archived agent or group only, and never an agent the host's seeds name, which the next start would seed again; it runs `cleanup`, your surface's part of the delete, after its checks and before deleting anything, so a cleanup that throws leaves the target in place to try again; then it frees the name, detaches the agent's skills, clears its group cursors and makes the runtime forget the conversations the name kept, and leaves a Discord channel under Archive), and `createGroup` and `updateGroup`. All of them throw `AgentError` with the reason, and fire the team's change signal.
|
|
3674
3677
|
- Breaking: `AgentGroup.channelId` is optional (`string | undefined`), and so is `GroupStatus.channelId`; a plugin that reads them handles a group without a Discord channel. The `agent_groups.channel_id` column drops its `NOT NULL` in a migration of the agent server (`agent-groups-channel-optional`), and `AgentServerOptions.guildId` and `entryChannelId` are optional, with `coordinator` added. `AvatarStudioOptions.publicUrl` is optional.
|
|
3675
3678
|
|
|
3679
|
+
#### A Discord bot without an agent guild
|
|
3680
|
+
|
|
3681
|
+
A bot that serves other guilds, through plugins' claims, slash commands and the owner's direct messages, can keep its agent team in the app: leave `discord.guild` out and keep `agents`.
|
|
3682
|
+
The team then runs exactly as [an agent team without Discord](#an-agent-team-without-discord): its id is `LOCAL_TEAM_ID`, every agent and group has its room only, `coordinator` names the coordinator, and temp knights get rooms.
|
|
3683
|
+
Leaving the guild out is the switch, rather than a separate flag, because the guild is what only the agents use: the Discord plugin itself never reads it, and an agent server in Discord needs it with `entryChannel` and `http.publicUrl`.
|
|
3684
|
+
|
|
3685
|
+
| `discord` | Without `guild` | With `guild` |
|
|
3686
|
+
| --- | --- | --- |
|
|
3687
|
+
| `guild` | Left out: no agent channels, categories, `#dashboard`, entry channel or agent threads, and nothing asks Discord for a guild on the agents' behalf | The agent server's guild |
|
|
3688
|
+
| `entryChannel` | A `ConfigError`: name the coordinator with `coordinator` | Required, unless `agentServer: false` |
|
|
3689
|
+
| `http.publicUrl` | Optional, as without Discord | Required, unless `agentServer: false` |
|
|
3690
|
+
| `agents` | Required, unless `agentServer: false` | Optional |
|
|
3691
|
+
| `coordinator`, a seed's `channelId`, `routing` naming `discord` for an agent | As without Discord: `coordinator` is allowed, the others are a `ConfigError` | As before |
|
|
3692
|
+
|
|
3693
|
+
- The Discord plugin connects and composes its commands as before: they are registered globally, so the root command (its `schedule` subcommands) and the commands plugins add work in every guild the bot is in. The core adds no agent-only slash command; a host that adds the agent panel itself (`agentPanel`) gets its "no agent here" answer outside agent channels.
|
|
3694
|
+
- Messages in the other guilds that no plugin claims are ignored as before: the agent server owns no Discord channel, since no agent or group has one and its team id is no guild's.
|
|
3695
|
+
- The agent tools are those of a team without Discord: `agent_list` lists the app's groups and no categories, `channel_arrange` and `channel_read` are not offered, and `message_agent`, the opening tasks, the agents' reports, background turns, error reports to an agent and the cards their turns raise all land in the agents' rooms.
|
|
3696
|
+
- The owner's direct messages with the bot stay the owner's own conversation, as on any Discord host: its cards and reports stay in the direct message. A card an agent's turn raises shows in that agent's room in the app.
|
|
3697
|
+
- Switching an existing host over starts a new team under `local`: the rows kept under the old guild's id (agents, groups, edited prompts, skills) are not read. The seeds are created again on the first start.
|
|
3698
|
+
|
|
3699
|
+
`roundtable doctor` skips the guild and entry channel checks when `discord.guild` has no value. `agentServer: false` takes `discord.guild` as optional too, since it has no agents.
|
|
3700
|
+
|
|
3676
3701
|
<!-- example: examples/headless.ts -->
|
|
3677
3702
|
```ts
|
|
3678
3703
|
import { definePlugin, type RoundtableConfig } from "pi-roundtable";
|
|
@@ -4231,7 +4256,7 @@ The same host may call `run()` again after that.
|
|
|
4231
4256
|
On `SIGTERM` or `SIGINT` the bot takes no new work at once, finishes what runs, and stops serving last:
|
|
4232
4257
|
|
|
4233
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.
|
|
4234
|
-
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.
|
|
4235
4260
|
3. Every plugin hears `shutdown(left)`, while every service is still running.
|
|
4236
4261
|
4. The HTTP listener closes, so no request reaches a service that has stopped.
|
|
4237
4262
|
5. Services stop in the reverse of the order they started.
|
|
@@ -4901,6 +4926,8 @@ Import from the entries listed below; source area files are internal.
|
|
|
4901
4926
|
| `JUDGE_WORK` | `pi-roundtable/kit` | value |
|
|
4902
4927
|
| `JevJudgeOptions` | `pi-roundtable/kit` | type |
|
|
4903
4928
|
| `McpEndpoint` | `pi-roundtable/kit` | type |
|
|
4929
|
+
| `McpToolHints` | `pi-roundtable/kit` | type |
|
|
4930
|
+
| `YOLO_NEVER_CLASS` | `pi-roundtable/kit` | value |
|
|
4904
4931
|
| `ModelRef` | `pi-roundtable/kit` | type |
|
|
4905
4932
|
| `OwnerIdentity` | `pi-roundtable/kit` | type |
|
|
4906
4933
|
| `Notifier` | `pi-roundtable/kit` | type |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-roundtable",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.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",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"canvas": "3.2.3",
|
|
72
72
|
"discord.js": "14.27.0",
|
|
73
73
|
"pi-jev-compaction": "1.0.0",
|
|
74
|
-
"pi-better-show": "0.
|
|
74
|
+
"pi-better-show": "0.4.0",
|
|
75
75
|
"pi-mcp-adapter": "5.3.0",
|
|
76
76
|
"pino": "10.4.0",
|
|
77
77
|
"typebox": "1.3.37",
|
|
@@ -50,9 +50,13 @@ export interface AgentClaimOptions {
|
|
|
50
50
|
* router resolved, `"owners"` only the owner tier; a webhook's report is the same either way.
|
|
51
51
|
*/
|
|
52
52
|
speakers?: "everyone" | "owners";
|
|
53
|
+
/**
|
|
54
|
+
* The Discord guild the agents' channels live in: a message from it is the agent server's even
|
|
55
|
+
* outside the channels it knows. Not the team's id; absent for a team without Discord channels.
|
|
56
|
+
*/
|
|
57
|
+
discordGuild?: string | undefined;
|
|
53
58
|
team: Pick<
|
|
54
59
|
DiscordAgentTeam,
|
|
55
|
-
| "guildId"
|
|
56
60
|
| "owns"
|
|
57
61
|
| "answerOwner"
|
|
58
62
|
| "answerGroup"
|
|
@@ -183,7 +187,7 @@ export function agentClaim(options: AgentClaimOptions): ChannelClaim {
|
|
|
183
187
|
owns: (channel, space) =>
|
|
184
188
|
discordIdOf(channel) !== undefined
|
|
185
189
|
? team.owns(channel) !== undefined ||
|
|
186
|
-
(space !== undefined && space ===
|
|
190
|
+
(space !== undefined && space === options.discordGuild)
|
|
187
191
|
: roomOf(channel, surface.roomSurfaces?.() ?? []) !== undefined &&
|
|
188
192
|
team.owns(channel) !== undefined,
|
|
189
193
|
admit: (message) => {
|
|
@@ -259,14 +259,20 @@ export const eventLog: string[] = [];
|
|
|
259
259
|
const PLUGIN_SELECTION = { tools: ["memory_add"], groups: ["workspace"] };
|
|
260
260
|
|
|
261
261
|
/**
|
|
262
|
-
* Waits until every queued channel task has settled
|
|
263
|
-
*
|
|
262
|
+
* Waits until every queued channel task has settled, every active agent has its avatar, which
|
|
263
|
+
* startup draws in the background, and every temp knight whose task ended is stamped finished
|
|
264
|
+
* (the stamp is written after the turn, off the queue; with an action held, a knight stays
|
|
265
|
+
* working); a fixed sleep was too short on a slow runner.
|
|
264
266
|
*/
|
|
265
267
|
export async function settle(): Promise<void> {
|
|
266
268
|
const deadline = Date.now() + 10_000;
|
|
267
269
|
const quiet = () =>
|
|
268
270
|
queue.busy().length === 0 &&
|
|
269
|
-
store.agents().every((a) => a.status !== "active" || a.avatarHash)
|
|
271
|
+
store.agents().every((a) => a.status !== "active" || a.avatarHash) &&
|
|
272
|
+
(runtime.held.size > 0 ||
|
|
273
|
+
store
|
|
274
|
+
.agents()
|
|
275
|
+
.every((a) => !a.parent || a.status !== "active" || a.finishedAt));
|
|
270
276
|
while (!quiet() && Date.now() < deadline) await Bun.sleep(5);
|
|
271
277
|
// Work the last task queued is still finishing.
|
|
272
278
|
await Bun.sleep(20);
|
|
@@ -91,6 +91,10 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
91
91
|
return this.#options.guildId;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
get discordGuild(): string | undefined {
|
|
95
|
+
return this.#options.discordGuild;
|
|
96
|
+
}
|
|
97
|
+
|
|
94
98
|
/** Called when a turn starts or ends and when an agent or group changes. */
|
|
95
99
|
onChange(listener: () => void): void {
|
|
96
100
|
this.#listeners.push(listener);
|
|
@@ -105,10 +109,7 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
105
109
|
return teamStatus(this.#context);
|
|
106
110
|
}
|
|
107
111
|
|
|
108
|
-
/**
|
|
109
|
-
* The agent or group that owns a channel of the agent server: by Discord channel, or by room on
|
|
110
|
-
* a surface that hosts rooms.
|
|
111
|
-
*/
|
|
112
|
+
/** The agent or group that owns a channel of the agent server, by Discord channel or by room. */
|
|
112
113
|
owns(channel: ChannelKey): "agent" | "group" | undefined {
|
|
113
114
|
const { store, surfaces } = this.#options;
|
|
114
115
|
return channelOwner(
|
|
@@ -120,10 +121,7 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
120
121
|
);
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
/**
|
|
124
|
-
* The name of the coordinator: the agent in the entry channel, or, on a host without Discord,
|
|
125
|
-
* the one the configuration names; undefined while none is active.
|
|
126
|
-
*/
|
|
124
|
+
/** The coordinator's name: the entry channel's agent, else the configured one; undefined while none is active. */
|
|
127
125
|
coordinator(): string | undefined {
|
|
128
126
|
return coordinatorOf(this.#options.store, this.#options)?.name;
|
|
129
127
|
}
|
|
@@ -177,6 +175,7 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
177
175
|
extension(scope: AgentTurnScope): ExtensionFactory {
|
|
178
176
|
return agentToolsExtension(this, scope, THE_SPEAKER, {
|
|
179
177
|
skills: this.#options.skills !== undefined,
|
|
178
|
+
channels: this.#options.channels !== undefined,
|
|
180
179
|
rooms: new TeamRooms(this.#options.store, () => this.#options.rooms?.()),
|
|
181
180
|
});
|
|
182
181
|
}
|
|
@@ -183,13 +183,18 @@ export interface AgentToolOptions {
|
|
|
183
183
|
skills: boolean;
|
|
184
184
|
/** The app's room groups; without them `group` and room_arrange are refused. */
|
|
185
185
|
rooms?: RoomOps;
|
|
186
|
+
/** Whether the team has Discord channels; without them no `category`, channel_arrange or channel_read. */
|
|
187
|
+
channels: boolean;
|
|
186
188
|
}
|
|
187
189
|
|
|
190
|
+
/** The tools that work on the team's Discord channels, left out of a team without them. */
|
|
191
|
+
const CHANNEL_TOOLS: readonly string[] = ["channel_arrange", "channel_read"];
|
|
192
|
+
|
|
188
193
|
function toolDefs(
|
|
189
194
|
ops: AgentOps,
|
|
190
195
|
scope: AgentTurnScope,
|
|
191
196
|
owner: OwnerIdentity,
|
|
192
|
-
{ skills: skillsOn, rooms }: AgentToolOptions,
|
|
197
|
+
{ skills: skillsOn, rooms, channels }: AgentToolOptions,
|
|
193
198
|
): AgentToolDef[] {
|
|
194
199
|
const o = ownerWords(owner);
|
|
195
200
|
const defs: AgentToolDef[] = [
|
|
@@ -273,7 +278,7 @@ function toolDefs(
|
|
|
273
278
|
maxLength: 4000,
|
|
274
279
|
description: "Its opening task, self-contained.",
|
|
275
280
|
}),
|
|
276
|
-
category: Type.Optional(category("Agents")),
|
|
281
|
+
...(channels ? { category: Type.Optional(category("Agents")) } : {}),
|
|
277
282
|
group: Type.Optional(ROOM_GROUP),
|
|
278
283
|
long_running: Type.Optional(
|
|
279
284
|
Type.Boolean({
|
|
@@ -339,7 +344,7 @@ function toolDefs(
|
|
|
339
344
|
display_name: DISPLAY,
|
|
340
345
|
members: MEMBERS,
|
|
341
346
|
host: Type.Optional(NAME),
|
|
342
|
-
category: Type.Optional(category("Groups")),
|
|
347
|
+
...(channels ? { category: Type.Optional(category("Groups")) } : {}),
|
|
343
348
|
group: Type.Optional(ROOM_GROUP),
|
|
344
349
|
}),
|
|
345
350
|
run: (i) => {
|
|
@@ -481,5 +486,8 @@ export function agentToolsExtension(
|
|
|
481
486
|
owner: OwnerIdentity,
|
|
482
487
|
options: AgentToolOptions,
|
|
483
488
|
): ExtensionFactory {
|
|
484
|
-
|
|
489
|
+
const defs = toolDefs(ops, scope, owner, options).filter(
|
|
490
|
+
(def) => options.channels || !CHANNEL_TOOLS.includes(def.name),
|
|
491
|
+
);
|
|
492
|
+
return textToolsExtension(defs, AgentError);
|
|
485
493
|
}
|
|
@@ -67,6 +67,11 @@ export interface RoutesOptions {
|
|
|
67
67
|
/** The conversation an agent last ran a turn in. */
|
|
68
68
|
latest?: (agent: string) => ChannelKey | undefined;
|
|
69
69
|
logger?: RoutesLogger;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the team has Discord channels; default true. A team without them has no Discord place
|
|
72
|
+
* for an agent: a channel id still stored on a row, such as one a former guild left, is ignored.
|
|
73
|
+
*/
|
|
74
|
+
discordChannels?: boolean;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
/** What the surfaces the host registered can hold, read when the agent server links. */
|
|
@@ -88,10 +93,24 @@ export class Routes implements RoutingTable {
|
|
|
88
93
|
readonly #routing: ResolvedRouting | undefined;
|
|
89
94
|
readonly #options: RoutesOptions;
|
|
90
95
|
readonly #warned = new Set<string>();
|
|
96
|
+
readonly #discordChannels: boolean;
|
|
91
97
|
|
|
92
98
|
constructor(options: RoutesOptions) {
|
|
93
99
|
this.#options = options;
|
|
94
100
|
this.#routing = options.routing;
|
|
101
|
+
this.#discordChannels = options.discordChannels ?? true;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The agent's places in order, its Discord channel first when the team has Discord channels. */
|
|
105
|
+
#keys(name: string): ChannelKey[] {
|
|
106
|
+
const keys = keysOf(
|
|
107
|
+
this.#options.store,
|
|
108
|
+
name,
|
|
109
|
+
this.#options.roomSurfaces(),
|
|
110
|
+
);
|
|
111
|
+
return this.#discordChannels
|
|
112
|
+
? keys
|
|
113
|
+
: keys.filter((key) => parseChannelKey(key).surface !== "discord");
|
|
95
114
|
}
|
|
96
115
|
|
|
97
116
|
/**
|
|
@@ -121,7 +140,9 @@ export class Routes implements RoutingTable {
|
|
|
121
140
|
? (rooms[0] as string)
|
|
122
141
|
: surface;
|
|
123
142
|
if (wanted === "discord")
|
|
124
|
-
return agent.channelId
|
|
143
|
+
return agent.channelId && this.#discordChannels
|
|
144
|
+
? discordKey(agent.channelId)
|
|
145
|
+
: undefined;
|
|
125
146
|
return rooms.includes(wanted) ? agentRoomKey(wanted, name) : undefined;
|
|
126
147
|
}
|
|
127
148
|
|
|
@@ -143,7 +164,7 @@ export class Routes implements RoutingTable {
|
|
|
143
164
|
"the agent has no place on its primary surface; its auto place is used",
|
|
144
165
|
);
|
|
145
166
|
}
|
|
146
|
-
return
|
|
167
|
+
return this.#keys(name)[0];
|
|
147
168
|
}
|
|
148
169
|
|
|
149
170
|
/**
|
|
@@ -225,11 +246,7 @@ export class Routes implements RoutingTable {
|
|
|
225
246
|
from === undefined ? undefined : parseChannelKey(from).surface;
|
|
226
247
|
if (to === "latest" && surface !== undefined) {
|
|
227
248
|
const last = latest?.(name);
|
|
228
|
-
const keys =
|
|
229
|
-
this.#options.store,
|
|
230
|
-
name,
|
|
231
|
-
this.#options.roomSurfaces(),
|
|
232
|
-
);
|
|
249
|
+
const keys = this.#keys(name);
|
|
233
250
|
if (
|
|
234
251
|
last !== undefined &&
|
|
235
252
|
keys.includes(last) &&
|
|
@@ -17,6 +17,8 @@ export interface AgentTeamOptions
|
|
|
17
17
|
* rows the team keeps.
|
|
18
18
|
*/
|
|
19
19
|
guildId: string;
|
|
20
|
+
/** The Discord guild the team's channels live in, which is not the team's id when the host sets one; absent without Discord channels. */
|
|
21
|
+
discordGuild?: string | undefined;
|
|
20
22
|
/** The first team, read and inserted once on start; an agent already stored is never overwritten. */
|
|
21
23
|
seeds: () => readonly AgentSeed[];
|
|
22
24
|
/** Sections the plugins add to every agent turn's system prompt, read before each run. */
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { ResolvedHelpers } from "../config/helpers.ts";
|
|
3
|
+
import type { ResolvedRouting } from "../config/routing.ts";
|
|
4
|
+
import type { ModelRef } from "../domain/models.ts";
|
|
5
|
+
import type { OwnerIdentity } from "../identity/owner-identity.ts";
|
|
6
|
+
import type { ErrorReporter } from "../ops/error-reporter.ts";
|
|
7
|
+
import type { AgentSessionsSlot } from "../runtime/runtime-plugin.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The id of a team that has no id of its own and no Discord guild: the rows the team keeps are
|
|
11
|
+
* stored under it.
|
|
12
|
+
*/
|
|
13
|
+
export const LOCAL_TEAM_ID = "local";
|
|
14
|
+
|
|
15
|
+
export interface AgentServerOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The Discord guild the team's channels live in. Absent on a host without Discord, or whose bot
|
|
18
|
+
* has no agent guild: the team has no channels, and its agents live in the rooms of the
|
|
19
|
+
* surfaces that host them. Without `teamId` the team is stored under the guild's id.
|
|
20
|
+
*/
|
|
21
|
+
guildId?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The id the team's rows are stored under, independent of the guild; default `guildId`, else
|
|
24
|
+
* `LOCAL_TEAM_ID`.
|
|
25
|
+
*/
|
|
26
|
+
teamId?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The ids the team was stored under before, such as a guild it no longer lives in: their rows
|
|
29
|
+
* move to `teamId` at every boot (`moveTeam`), and, without Discord channels, lose the channel
|
|
30
|
+
* ids they carried.
|
|
31
|
+
*/
|
|
32
|
+
formerTeamIds?: readonly string[];
|
|
33
|
+
/** The channel the coordinator lives in; set with `guildId`, never with `coordinator`. */
|
|
34
|
+
entryChannelId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The coordinator's name on a host without Discord, where no entry channel names it; the first
|
|
37
|
+
* seed when absent. Refused with `entryChannelId`.
|
|
38
|
+
*/
|
|
39
|
+
coordinator?: string;
|
|
40
|
+
owner: OwnerIdentity & { id: string };
|
|
41
|
+
/** The assistant's display name, as the confirmation judge names it. */
|
|
42
|
+
assistant: string;
|
|
43
|
+
/** Shared with the rest of the host, so logins refresh in one place; lists the models an agent may run. */
|
|
44
|
+
modelRuntime: ModelRuntime;
|
|
45
|
+
dataDir: string;
|
|
46
|
+
/** The model of agents and of the assistant. */
|
|
47
|
+
model: ModelRef;
|
|
48
|
+
/** How sure the confirmation judge must be before its answer is used. */
|
|
49
|
+
judgeThreshold: number;
|
|
50
|
+
/** Where the agent server hands the runtime plugin its per-agent settings. */
|
|
51
|
+
agents?: AgentSessionsSlot;
|
|
52
|
+
/** The shell's shared working directory. */
|
|
53
|
+
workDir: string;
|
|
54
|
+
/**
|
|
55
|
+
* The agents' scratch dir, created with mode 0700 when the agent server starts: their shell's
|
|
56
|
+
* TMPDIR, where writes and removals run without a hold.
|
|
57
|
+
*/
|
|
58
|
+
scratchDir?: string;
|
|
59
|
+
/** The host account the agents' shell and file tools run as. */
|
|
60
|
+
shellUser: string;
|
|
61
|
+
/**
|
|
62
|
+
* Whose turns in the agents' channels load memory: `"everyone"` (the default) or `"owners"`;
|
|
63
|
+
* see `AgentSessions.memory`.
|
|
64
|
+
*/
|
|
65
|
+
memory?: "everyone" | "owners";
|
|
66
|
+
/**
|
|
67
|
+
* Who the agents answer in their channels and groups' channels: `"everyone"` (the default) or
|
|
68
|
+
* `"owners"`, which leaves a speaker below the owner tier unanswered.
|
|
69
|
+
*/
|
|
70
|
+
speakers?: "everyone" | "owners";
|
|
71
|
+
/**
|
|
72
|
+
* Limits of the downloads of a message's files (`discord.attachmentDownload`): `deadlineMs`
|
|
73
|
+
* for all of a message's files together (default 60 s), `idleMs` for one file to send no byte
|
|
74
|
+
* (default 10 s).
|
|
75
|
+
*/
|
|
76
|
+
attachmentDownload?: { deadlineMs?: number; idleMs?: number };
|
|
77
|
+
/** The prompt every agent starts with, and the one for speakers other than the owner. */
|
|
78
|
+
prompts: { shared: string; guest?: string };
|
|
79
|
+
/** The listener the avatar pictures are served on; none mounts no route, and a surface serves them through `AGENTS.avatars.serve`. */
|
|
80
|
+
avatarListener?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The origin the agents' pictures are served from. Without one a picture's URL is
|
|
83
|
+
* `/avatars/<hash>.png`, which the surface that serves the pictures resolves against its origin.
|
|
84
|
+
*/
|
|
85
|
+
avatarUrl?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Render every agent's picture again at start (`characters.refreshAvatars`) and set it where
|
|
88
|
+
* its hash differs from the stored one; default false.
|
|
89
|
+
*/
|
|
90
|
+
refreshAvatars?: boolean;
|
|
91
|
+
/** The assistant's neutral avatar: the style reference and the picture of an agent without one. */
|
|
92
|
+
avatarReference: string;
|
|
93
|
+
/** The picture used instead when `avatarReference` cannot be read as one; the failure is logged. */
|
|
94
|
+
avatarNeutral?: string;
|
|
95
|
+
/** Reports the process's own errors to an agent; without one nothing is reported. */
|
|
96
|
+
errorReporter?: ErrorReporter;
|
|
97
|
+
/** The checked `routing` block: where work no person started lands. Without it every place is what it was before `routing`. */
|
|
98
|
+
routing?: ResolvedRouting;
|
|
99
|
+
/** The temp knights' limits; `false` leaves `helper_create` and `helper_end` out. Without it the defaults apply. */
|
|
100
|
+
helpers?: ResolvedHelpers | false;
|
|
101
|
+
}
|