pi-roundtable 0.34.0 → 0.35.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 (257) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -2
  3. package/src/cli/checks/configuration.ts +2 -2
  4. package/src/cli/checks/database.ts +2 -2
  5. package/src/cli/checks/identity.ts +1 -1
  6. package/src/cli/checks/model.ts +1 -1
  7. package/src/cli/cli.ts +2 -2
  8. package/src/cli/principal.ts +1 -1
  9. package/src/cli/project.ts +2 -2
  10. package/src/cli/runtime.ts +3 -3
  11. package/src/cli/start.ts +1 -1
  12. package/src/core/agents/agent-claim.ts +4 -4
  13. package/src/core/agents/agent-dashboard.ts +3 -3
  14. package/src/core/agents/agent-messages.ts +2 -2
  15. package/src/core/agents/agent-outbox.ts +1 -1
  16. package/src/core/agents/agent-ports.ts +1 -1
  17. package/src/core/agents/agent-prompt.ts +4 -4
  18. package/src/core/agents/agent-rules.ts +1 -1
  19. package/src/core/agents/agent-schema.ts +4 -1
  20. package/src/core/agents/agent-settings.ts +2 -2
  21. package/src/core/agents/agent-store.ts +9 -9
  22. package/src/core/agents/agent-team-fixture.ts +4 -3
  23. package/src/core/agents/agent-team.ts +12 -16
  24. package/src/core/agents/agent-tools.ts +15 -15
  25. package/src/core/agents/avatar-refresh.ts +1 -1
  26. package/src/core/agents/avatar-studio.ts +2 -2
  27. package/src/core/agents/group-round.ts +2 -2
  28. package/src/core/agents/group-turns.ts +1 -1
  29. package/src/core/agents/helper-create.ts +24 -40
  30. package/src/core/agents/helper-modes.ts +2 -2
  31. package/src/core/agents/helper-preset-ops.ts +207 -0
  32. package/src/core/agents/helper-preset-tools.ts +109 -0
  33. package/src/core/agents/helper-presets.ts +128 -0
  34. package/src/core/agents/helper-test-kit.ts +1 -1
  35. package/src/core/agents/helper-tools.ts +42 -22
  36. package/src/core/agents/helper-work.ts +1 -1
  37. package/src/core/agents/message-target.ts +1 -1
  38. package/src/core/agents/routes.ts +1 -1
  39. package/src/core/agents/team-approval.ts +2 -2
  40. package/src/core/agents/team-editing.ts +2 -2
  41. package/src/core/agents/team-keys.ts +1 -1
  42. package/src/core/agents/team-layout.ts +1 -1
  43. package/src/core/agents/team-options.ts +4 -4
  44. package/src/core/agents/team-selection.ts +1 -1
  45. package/src/core/agents/team-status.ts +1 -1
  46. package/src/core/agents/team-text.ts +3 -3
  47. package/src/core/agents/team-turn-types.ts +7 -7
  48. package/src/core/agents/team-turns.ts +3 -3
  49. package/src/core/attachments/attachment-fetcher.ts +1 -1
  50. package/src/core/attachments/attachment-port.ts +2 -2
  51. package/src/core/attachments/attachment-retention.ts +3 -3
  52. package/src/core/attachments/attachment-store.ts +2 -2
  53. package/src/core/attachments/model-images.ts +1 -1
  54. package/src/core/attachments/turn-attachments.ts +1 -1
  55. package/src/core/builtin/agent-server.ts +17 -10
  56. package/src/core/builtin/channel-context.ts +2 -2
  57. package/src/core/builtin/discord-admin.ts +2 -2
  58. package/src/core/builtin/discord.ts +4 -3
  59. package/src/core/{identity/identity-plugin.ts → builtin/identity.ts} +15 -12
  60. package/src/core/builtin/modules.ts +12 -12
  61. package/src/core/builtin/prompts.ts +3 -3
  62. package/src/core/builtin/seeds.ts +1 -1
  63. package/src/core/builtin/session-tool.ts +1 -1
  64. package/src/core/builtin/skills.ts +3 -3
  65. package/src/core/builtin/stores.ts +10 -5
  66. package/src/core/builtin/threads.ts +2 -2
  67. package/src/core/builtin/worker-sessions.ts +3 -3
  68. package/src/core/config/access.ts +3 -3
  69. package/src/core/config/adapters.ts +1 -1
  70. package/src/core/config/config-schema.ts +9 -3
  71. package/src/core/config/config.ts +9 -10
  72. package/src/core/config/ops.ts +1 -1
  73. package/src/core/config/peer-bots.ts +74 -0
  74. package/src/core/config/routing.ts +1 -1
  75. package/src/core/contract/attachments.ts +1 -1
  76. package/src/core/contract/channels.ts +3 -5
  77. package/src/core/contract/runtime.ts +6 -6
  78. package/src/core/contract/surface.ts +3 -3
  79. package/src/core/conversations/conversation-registry.ts +1 -1
  80. package/src/core/conversations/conversation-retention.ts +2 -2
  81. package/src/core/conversations/conversation-store.ts +1 -1
  82. package/src/core/conversations/conversations-plugin.ts +2 -2
  83. package/src/core/db/migrations.ts +2 -2
  84. package/src/core/discord/agent-commands.ts +2 -2
  85. package/src/core/discord/agent-discord.ts +1 -1
  86. package/src/core/discord/agent-panel.ts +1 -1
  87. package/src/core/discord/card-audience.ts +1 -1
  88. package/src/core/discord/card-copies.ts +1 -1
  89. package/src/core/discord/channel-context.ts +1 -1
  90. package/src/core/discord/channel-executor.ts +1 -1
  91. package/src/core/discord/channel-operations.ts +1 -1
  92. package/src/core/discord/command-collection.ts +1 -1
  93. package/src/core/discord/compose-commands.ts +1 -1
  94. package/src/core/discord/context-images.ts +1 -1
  95. package/src/core/discord/discord-owners.ts +2 -2
  96. package/src/core/discord/discord-surface.ts +2 -2
  97. package/src/core/discord/member-events.ts +2 -2
  98. package/src/core/discord/message-changes.ts +1 -1
  99. package/src/core/discord/owner-cards.ts +1 -1
  100. package/src/core/discord/owner-command.ts +1 -1
  101. package/src/core/discord/schedule-commands.ts +1 -1
  102. package/src/core/domain/conversation.ts +5 -3
  103. package/src/core/{models.ts → domain/models.ts} +1 -1
  104. package/src/core/domain/ports.ts +2 -2
  105. package/src/core/{sessions.ts → domain/sessions.ts} +6 -6
  106. package/src/core/{define-roundtable.ts → host/define-roundtable.ts} +29 -29
  107. package/src/core/{drain.ts → host/drain.ts} +2 -7
  108. package/src/core/{events.ts → host/events.ts} +2 -2
  109. package/src/core/{host-background.ts → host/host-background.ts} +3 -3
  110. package/src/core/{host-registration.ts → host/host-registration.ts} +30 -30
  111. package/src/core/{host.ts → host/host.ts} +19 -15
  112. package/src/core/http/listeners.ts +2 -2
  113. package/src/core/http/websocket.ts +1 -1
  114. package/src/core/identity/access-policy.ts +8 -8
  115. package/src/core/identity/actor-facts.ts +1 -1
  116. package/src/core/identity/caching-principal-store.ts +1 -1
  117. package/src/core/identity/config-owner.ts +1 -1
  118. package/src/core/identity/contact.ts +2 -2
  119. package/src/core/identity/identity-links.ts +2 -2
  120. package/src/core/identity/identity-port.ts +2 -2
  121. package/src/core/identity/identity-schema.ts +1 -1
  122. package/src/core/identity/identity-service.ts +3 -3
  123. package/src/core/identity/identity-view.ts +1 -1
  124. package/src/core/{identity.ts → identity/owner-identity.ts} +1 -1
  125. package/src/core/identity/person-profiles.ts +1 -1
  126. package/src/core/identity/plugin-identities.ts +2 -2
  127. package/src/core/identity/principal-reads.ts +1 -1
  128. package/src/core/identity/principal-store.ts +1 -1
  129. package/src/core/identity/principal-types.ts +1 -1
  130. package/src/core/identity/seen-throttle.ts +1 -1
  131. package/src/core/{speakers.ts → identity/speakers.ts} +3 -6
  132. package/src/core/images/codex-images-plugin.ts +3 -3
  133. package/src/core/interactions/prompts.ts +1 -1
  134. package/src/core/judging/confirmation-judge.ts +1 -1
  135. package/src/core/judging/effort-judge.ts +2 -2
  136. package/src/core/judging/model-judge.ts +1 -1
  137. package/src/core/modes/conversation-modes.ts +4 -4
  138. package/src/core/modes/mode-inheritance.ts +1 -1
  139. package/src/core/modes/modes-plugin.ts +2 -2
  140. package/src/core/modules/background/background-turns.ts +4 -4
  141. package/src/core/modules/delegation/delegate.ts +3 -3
  142. package/src/core/modules/delegation/delegator.ts +4 -4
  143. package/src/core/modules/delegation/web-research-worker.ts +2 -2
  144. package/src/core/modules/delegation/worker-session.ts +5 -2
  145. package/src/core/modules/discord-admin/discord-admin.ts +1 -1
  146. package/src/core/modules/host-shell/shell-policy.ts +1 -1
  147. package/src/core/modules/memory/owner-memory-store.ts +1 -1
  148. package/src/core/modules/memory/owner-memory.ts +6 -3
  149. package/src/core/modules/notify/notify.ts +4 -1
  150. package/src/core/modules/notify/session-notify.ts +3 -3
  151. package/src/core/modules/prompts/prompt-documents.ts +1 -1
  152. package/src/core/modules/schedules/precheck-tools.ts +4 -4
  153. package/src/core/modules/schedules/prechecks.ts +2 -2
  154. package/src/core/modules/schedules/recurrence.ts +6 -1
  155. package/src/core/modules/schedules/schedule-prechecks.ts +4 -4
  156. package/src/core/modules/schedules/schedule-store.ts +2 -2
  157. package/src/core/modules/schedules/schedule-tools.ts +4 -4
  158. package/src/core/modules/schedules/scheduled-turn-text.ts +1 -1
  159. package/src/core/modules/schedules/scheduler.ts +3 -3
  160. package/src/core/modules/schedules/schedules.ts +5 -5
  161. package/src/core/modules/skills/missing-warning.ts +1 -1
  162. package/src/core/modules/skills/package-skills.ts +1 -1
  163. package/src/core/modules/skills/skill-registry.ts +2 -2
  164. package/src/core/modules/skills/skill-rules.ts +1 -1
  165. package/src/core/modules/skills/skill-tools.ts +1 -1
  166. package/src/core/ops/error-reporter.ts +2 -2
  167. package/src/core/ops/ops-alerts.ts +1 -1
  168. package/src/core/{define.ts → plugin-api/define.ts} +18 -20
  169. package/src/core/{event-types.ts → plugin-api/event-types.ts} +1 -1
  170. package/src/core/{holds.ts → plugin-api/holds.ts} +3 -3
  171. package/src/core/{plugin-removed.ts → plugin-api/plugin-removed.ts} +2 -2
  172. package/src/core/{plugin.ts → plugin-api/plugin.ts} +26 -26
  173. package/src/core/{services.ts → plugin-api/services.ts} +28 -28
  174. package/src/core/{tool-turn.ts → plugin-api/tool-turn.ts} +12 -5
  175. package/src/core/presence/delivery-router.ts +1 -1
  176. package/src/core/presence/direct-channels.ts +1 -1
  177. package/src/core/registry/chat-commands.ts +1 -1
  178. package/src/core/registry/contributions.ts +11 -11
  179. package/src/core/registry/providers.ts +2 -2
  180. package/src/core/registry/services.ts +2 -2
  181. package/src/core/registry/surface-service.ts +1 -1
  182. package/src/core/routing/actor-of.ts +1 -1
  183. package/src/core/routing/channel-queue.ts +2 -2
  184. package/src/core/routing/channel-router.ts +3 -3
  185. package/src/core/routing/claim-events.ts +2 -2
  186. package/src/core/routing/conversation-turns.ts +10 -6
  187. package/src/core/routing/forward-join.ts +1 -1
  188. package/src/core/routing/message-observers.ts +1 -1
  189. package/src/core/routing/message-text.ts +1 -1
  190. package/src/core/routing/peer-bots.ts +6 -74
  191. package/src/core/routing/queued-messages.ts +2 -2
  192. package/src/core/routing/settle-turn.ts +1 -1
  193. package/src/core/routing/surface-port.ts +3 -3
  194. package/src/core/runtime/ask-questions.ts +1 -1
  195. package/src/core/runtime/bridge-guard.ts +5 -5
  196. package/src/core/runtime/chat-only.ts +1 -1
  197. package/src/core/runtime/conversation-sessions.ts +2 -2
  198. package/src/core/runtime/extensions/agent-prompt.ts +1 -1
  199. package/src/core/runtime/extensions/ask-user-text.ts +5 -1
  200. package/src/core/runtime/extensions/ask-user.ts +4 -1
  201. package/src/core/runtime/extensions/card-ask.ts +1 -1
  202. package/src/core/runtime/extensions/confirmation-fixture.ts +1 -1
  203. package/src/core/runtime/extensions/confirmation-gate-extension.ts +1 -1
  204. package/src/core/runtime/extensions/confirmation-gate.ts +5 -5
  205. package/src/core/runtime/extensions/gate-refusals.ts +5 -2
  206. package/src/core/runtime/extensions/held-calls.ts +2 -2
  207. package/src/core/runtime/extensions/hold-describer.ts +3 -3
  208. package/src/core/runtime/extensions/hold-lookups.ts +4 -4
  209. package/src/core/runtime/extensions/persona-prompt.ts +1 -1
  210. package/src/core/runtime/extensions/prompt-read.ts +1 -1
  211. package/src/core/runtime/extensions/yolo.ts +1 -1
  212. package/src/core/runtime/interim-text.ts +1 -1
  213. package/src/core/runtime/pi-agent-runtime.ts +4 -4
  214. package/src/core/runtime/running-turn.ts +1 -1
  215. package/src/core/runtime/runtime-plugin.ts +13 -8
  216. package/src/core/runtime/runtime-types.ts +14 -10
  217. package/src/core/runtime/session-conversation.ts +3 -3
  218. package/src/core/runtime/session-factory.ts +5 -5
  219. package/src/core/runtime/thinking-level.ts +2 -2
  220. package/src/core/{tool-tiers.ts → runtime/tool-tiers.ts} +5 -5
  221. package/src/core/runtime/turn-answer.ts +1 -1
  222. package/src/core/runtime/turn-budget.ts +1 -1
  223. package/src/core/runtime/turn-limits.ts +1 -1
  224. package/src/core/runtime/turn-tools.ts +2 -2
  225. package/src/core/runtime/worker-task.ts +1 -1
  226. package/src/core/shared/attach-file-tool.ts +1 -1
  227. package/src/core/shared/delegate-tool.ts +1 -1
  228. package/src/core/shared/generate-image-tool.ts +1 -1
  229. package/src/core/{modules/background → shared}/personal-target.ts +2 -2
  230. package/src/core/{reply-files.ts → shared/reply-files.ts} +1 -1
  231. package/src/core/testing/eager-catalog.ts +1 -1
  232. package/src/core/testing/locale.ts +1 -1
  233. package/src/core/testing/map-identity.ts +5 -1
  234. package/src/core/testing/module-sessions.ts +3 -3
  235. package/src/core/testing/modules.ts +17 -13
  236. package/src/core/testing/owner.ts +2 -2
  237. package/src/core/testing/recording-logger.ts +1 -1
  238. package/src/core/testing/run-tool.ts +2 -2
  239. package/src/core/testing/surface-contract-support.ts +1 -1
  240. package/src/core/testing/surface-contract.ts +2 -2
  241. package/src/core/testing/test-host.ts +12 -12
  242. package/src/core/testing/thread-host.ts +1 -1
  243. package/src/core/testing/tool-set.ts +3 -3
  244. package/src/core/threads/dispatch-threads.ts +1 -1
  245. package/src/core/tool-set.snapshot.json +12 -0
  246. package/src/index.ts +76 -72
  247. package/src/kit/domain.ts +9 -9
  248. package/src/kit/holds.ts +4 -1
  249. package/src/kit/jev-judge.ts +1 -1
  250. package/src/kit/jev.ts +1 -1
  251. package/src/kit/presentation.ts +1 -1
  252. package/src/kit/support.ts +3 -3
  253. package/src/testing.ts +21 -20
  254. /package/src/core/{errors.ts → kernel/errors.ts} +0 -0
  255. /package/src/core/{freeze.ts → kernel/freeze.ts} +0 -0
  256. /package/src/core/{log.ts → kernel/log.ts} +0 -0
  257. /package/src/core/{time.ts → kernel/time.ts} +0 -0
@@ -2,10 +2,10 @@ import type { OutboundReply, PostAuthor } from "../domain/conversation.ts";
2
2
  import type { InterimMessage, InterimPosts } from "../domain/interim.ts";
3
3
  import type { TurnProgress } from "../domain/progress.ts";
4
4
  import type { RoundProgress } from "../domain/round.ts";
5
- import { PluginError } from "../errors.ts";
5
+ import type { ChannelKey } from "../domain/sessions.ts";
6
+ import type { Speaker } from "../identity/speakers.ts";
6
7
  import type { PromptScope, Prompts } from "../interactions/prompts.ts";
7
- import type { ChannelKey } from "../sessions.ts";
8
- import type { Speaker } from "../speakers.ts";
8
+ import { PluginError } from "../kernel/errors.ts";
9
9
  import type {
10
10
  ChannelContext,
11
11
  ChannelContextOptions,
@@ -1,4 +1,4 @@
1
- import type { ChannelKey } from "../sessions.ts";
1
+ import type { ChannelKey } from "../domain/sessions.ts";
2
2
 
3
3
  /** Who may take part: `private` belongs to one principal, `shared` to whoever its claim admits. */
4
4
  export type ConversationVisibility = "private" | "shared";
@@ -1,6 +1,6 @@
1
1
  import type { ConversationPort } from "../contract/channels.ts";
2
- import type { Logger } from "../log.ts";
3
- import type { Service } from "../plugin.ts";
2
+ import type { Logger } from "../kernel/log.ts";
3
+ import type { Service } from "../plugin-api/plugin.ts";
4
4
  import type {
5
5
  ConversationRecord,
6
6
  ConversationRegistry,
@@ -1,7 +1,7 @@
1
1
  import type { SQL } from "bun";
2
2
  import { parseChannelKey } from "../contract/surface.ts";
3
3
  import type { Migration } from "../db/migrations.ts";
4
- import type { ChannelKey } from "../sessions.ts";
4
+ import type { ChannelKey } from "../domain/sessions.ts";
5
5
  import type {
6
6
  ConversationRecord,
7
7
  ConversationRegistration,
@@ -1,6 +1,6 @@
1
1
  import type { SQL } from "bun";
2
- import type { RoundtablePlugin } from "../plugin.ts";
3
- import { CONVERSATIONS } from "../services.ts";
2
+ import type { RoundtablePlugin } from "../plugin-api/plugin.ts";
3
+ import { CONVERSATIONS } from "../plugin-api/services.ts";
4
4
  import type { ConversationRegistry } from "./conversation-registry.ts";
5
5
  import {
6
6
  type ConversationRetentionOptions,
@@ -1,6 +1,6 @@
1
1
  import { SQL, type TransactionSQL } from "bun";
2
- import { MigrationError, PluginError } from "../errors.ts";
3
- import type { RoundtablePlugin } from "../plugin.ts";
2
+ import { MigrationError, PluginError } from "../kernel/errors.ts";
3
+ import type { RoundtablePlugin } from "../plugin-api/plugin.ts";
4
4
 
5
5
  /** A plugin's tables, as DDL its `up` runs. */
6
6
  export interface Migration {
@@ -30,8 +30,8 @@ import {
30
30
  import { characterOf } from "../agents/agent-rules.ts";
31
31
  import { type Agent, MAX_PROMPT_CHARS } from "../agents/agent-store.ts";
32
32
  import { AgentError } from "../domain/errors.ts";
33
+ import { THINKING_LEVELS, thinkingLabel } from "../domain/models.ts";
33
34
  import { messages } from "../i18n/index.ts";
34
- import { THINKING_LEVELS, thinkingLabel } from "../models.ts";
35
35
  import {
36
36
  BUILTIN_SKILLS,
37
37
  type SkillSet,
@@ -41,7 +41,7 @@ import type {
41
41
  AgentTeam,
42
42
  AvatarStudio,
43
43
  SkillRegistry,
44
- } from "../services.ts";
44
+ } from "../plugin-api/services.ts";
45
45
  import { OwnerFacingError, ownerPanel } from "./owner-panel.ts";
46
46
 
47
47
  /** The custom-id prefixes of the panel's buttons and forms; posted panels carry them, so they never change. */
@@ -27,7 +27,7 @@ import type {
27
27
  import { AgentError } from "../domain/errors.ts";
28
28
  import type { InterimPosts } from "../domain/interim.ts";
29
29
  import { messages } from "../i18n/index.ts";
30
- import type { Logger } from "../log.ts";
30
+ import type { Logger } from "../kernel/log.ts";
31
31
  import { type IntercomTexts, intercomPost } from "./intercom-cards.ts";
32
32
 
33
33
  const DASHBOARD_NAME = "dashboard";
@@ -1,5 +1,5 @@
1
1
  import { type Interaction, MessageFlags } from "discord.js";
2
- import type { AgentServer, SkillRegistry } from "../services.ts";
2
+ import type { AgentServer, SkillRegistry } from "../plugin-api/services.ts";
3
3
  import {
4
4
  AGENT_BUTTON_PREFIX,
5
5
  AGENT_MODAL_PREFIX,
@@ -1,6 +1,6 @@
1
1
  import { messages } from "../i18n/index.ts";
2
+ import { type Tier, tierAtLeast } from "../identity/speakers.ts";
2
3
  import type { ApprovedBy, PromptScope } from "../interactions/prompts.ts";
3
- import { type Tier, tierAtLeast } from "../speakers.ts";
4
4
  import type {
5
5
  DiscordOwners,
6
6
  DiscordOwnersOptions,
@@ -3,7 +3,7 @@ import { chmod, mkdir, rename, writeFile } from "node:fs/promises";
3
3
  import { dirname } from "node:path";
4
4
  import { AttachmentBuilder, MessageFlags } from "discord.js";
5
5
  import { messages } from "../i18n/index.ts";
6
- import type { Logger } from "../log.ts";
6
+ import type { Logger } from "../kernel/log.ts";
7
7
 
8
8
  /** The most characters of one card's copy text; a longer one gets no copy button. */
9
9
  export const COPY_TEXT_LIMIT = 20_000;
@@ -12,7 +12,7 @@ import {
12
12
  import type { InboundMessage } from "../contract/channels.ts";
13
13
  import { parseChannelKey } from "../contract/surface.ts";
14
14
  import { MAX_TURN_IMAGES } from "../domain/attachment.ts";
15
- import type { Logger } from "../log.ts";
15
+ import type { Logger } from "../kernel/log.ts";
16
16
  import { contextImages, type SkippedImage } from "./context-images.ts";
17
17
  import { embedText } from "./embed-text.ts";
18
18
  import type { BotIdentity } from "./inbound-message.ts";
@@ -11,7 +11,7 @@ import {
11
11
  type PermissionResolvable,
12
12
  type TextChannel,
13
13
  } from "discord.js";
14
- import { freeze } from "../freeze.ts";
14
+ import { freeze } from "../kernel/freeze.ts";
15
15
  import type { ChannelOperation } from "./channel-operations.ts";
16
16
  import {
17
17
  type ChannelExecutor,
@@ -1,7 +1,7 @@
1
1
  import { type TSchema, Type } from "typebox";
2
2
  import Value from "typebox/value";
3
- import { freeze } from "../freeze.ts";
4
3
  import { type Messages, messages } from "../i18n/index.ts";
4
+ import { freeze } from "../kernel/freeze.ts";
5
5
 
6
6
  /** What a call may do in one channel, with the owner-facing label; grants and permission checks name these. */
7
7
  export const CHANNEL_OPERATIONS = Object.freeze([
@@ -1,4 +1,4 @@
1
- import { PluginError } from "../errors.ts";
1
+ import { PluginError } from "../kernel/errors.ts";
2
2
  import { type ComposedCommands, composeCommands } from "./compose-commands.ts";
3
3
  import type {
4
4
  CommandRegistrar,
@@ -2,7 +2,7 @@ import {
2
2
  type RESTPostAPIChatInputApplicationCommandsJSONBody,
3
3
  SlashCommandBuilder,
4
4
  } from "discord.js";
5
- import { PluginError } from "../errors.ts";
5
+ import { PluginError } from "../kernel/errors.ts";
6
6
  import type {
7
7
  CommandRoot,
8
8
  InteractionContribution,
@@ -5,7 +5,7 @@ import {
5
5
  } from "../attachments/image-prep.ts";
6
6
  import type { ChannelContextAttachment } from "../contract/channel-context.ts";
7
7
  import type { ModelImage } from "../domain/attachment.ts";
8
- import type { Logger } from "../log.ts";
8
+ import type { Logger } from "../kernel/log.ts";
9
9
 
10
10
  /** Why an image of a channel message was not attached to the turn; fixed words, never an error's text. */
11
11
  export type SkippedReason =
@@ -1,6 +1,6 @@
1
1
  import type { IdentityService } from "../identity/identity-service.ts";
2
- import type { Logger } from "../log.ts";
3
- import { type Speaker, type Tier, tierAtLeast } from "../speakers.ts";
2
+ import { type Speaker, type Tier, tierAtLeast } from "../identity/speakers.ts";
3
+ import type { Logger } from "../kernel/log.ts";
4
4
 
5
5
  /** A Discord user who pressed or ran something; their roles are unknown where the interaction carries no member. */
6
6
  export interface DiscordUser {
@@ -25,11 +25,11 @@ import type {
25
25
  } from "../domain/conversation.ts";
26
26
  import type { InterimPosts } from "../domain/interim.ts";
27
27
  import type { OwnerNotifier } from "../domain/ports.ts";
28
- import type { MemberJoinedEvent } from "../event-types.ts";
29
28
  import { messages } from "../i18n/index.ts";
30
29
  import type { PromptScope, Prompts } from "../interactions/prompts.ts";
31
- import type { Logger } from "../log.ts";
30
+ import type { Logger } from "../kernel/log.ts";
32
31
  import type { OwnerOperations } from "../modules/discord-admin/discord-admin.ts";
32
+ import type { MemberJoinedEvent } from "../plugin-api/event-types.ts";
33
33
  import { splitReply } from "../presentation/reply-splitter.ts";
34
34
  import { threadsOfHost } from "../threads/host-threads.ts";
35
35
  import { DiscordAgentChannels, DiscordDashboard } from "./agent-discord.ts";
@@ -1,6 +1,6 @@
1
1
  import { type Client, Events, GatewayIntentBits } from "discord.js";
2
- import type { MemberJoinedEvent } from "../event-types.ts";
3
- import type { Logger } from "../log.ts";
2
+ import type { Logger } from "../kernel/log.ts";
3
+ import type { MemberJoinedEvent } from "../plugin-api/event-types.ts";
4
4
 
5
5
  /** The privileged Server Members intent, asked for only when the host turns `discord.memberEvents` on. */
6
6
  export function memberIntents(
@@ -2,7 +2,7 @@ import { type Client, Events } from "discord.js";
2
2
  import type { InboundMessage } from "../contract/channels.ts";
3
3
  import type { SurfaceMessageEvents } from "../contract/surface.ts";
4
4
  import { channelKey } from "../contract/surface.ts";
5
- import type { Logger } from "../log.ts";
5
+ import type { Logger } from "../kernel/log.ts";
6
6
  import { toInbound } from "./inbound-message.ts";
7
7
 
8
8
  /** Hands every message the client sees to `deliver` as the neutral message; the bot's own are left out. */
@@ -8,7 +8,7 @@ import type {
8
8
  PromptScope,
9
9
  Prompts,
10
10
  } from "../interactions/prompts.ts";
11
- import type { Logger } from "../log.ts";
11
+ import type { Logger } from "../kernel/log.ts";
12
12
  import { type CardAudienceOptions, CardAudiences } from "./card-audience.ts";
13
13
  import { CardCopies, copyReply, offeredCopy } from "./card-copies.ts";
14
14
  import { DiscordOwners, discordUser } from "./discord-owners.ts";
@@ -8,7 +8,7 @@ import {
8
8
  } from "discord.js";
9
9
  import { messages } from "../i18n/index.ts";
10
10
  import type { IdentityService } from "../identity/identity-service.ts";
11
- import type { Logger } from "../log.ts";
11
+ import type { Logger } from "../kernel/log.ts";
12
12
  import {
13
13
  type DiscordActor,
14
14
  DiscordOwners,
@@ -6,7 +6,7 @@ import type {
6
6
  import { messages } from "../i18n/index.ts";
7
7
  import { describeRecurrence } from "../modules/schedules/recurrence.ts";
8
8
  import type { Schedule } from "../modules/schedules/schedule-store.ts";
9
- import type { ScheduleStore } from "../services.ts";
9
+ import type { ScheduleStore } from "../plugin-api/services.ts";
10
10
  import type {
11
11
  CommandGuard,
12
12
  InteractionContribution,
@@ -1,8 +1,10 @@
1
1
  import type { InboundMessage } from "../contract/channels.ts";
2
- import type { ChannelKey } from "../sessions.ts";
3
- import type { Tier } from "../speakers.ts";
2
+ import type { Tier } from "../identity/speakers.ts";
3
+ import type { ChannelKey } from "./sessions.ts";
4
4
 
5
- export { QUEUED_MARK, STEERED_MARK } from "../contract/channels.ts";
5
+ /** Reactions on a message sent during a turn: added to that turn, or waiting for its own. */
6
+ export const STEERED_MARK = "↪️";
7
+ export const QUEUED_MARK = "⏳";
6
8
  export type { ChannelKey, InboundMessage };
7
9
 
8
10
  export interface TranscriptEntry {
@@ -1,4 +1,4 @@
1
- import { messages } from "./i18n/index.ts";
1
+ import { messages } from "../i18n/index.ts";
2
2
  import type { ChannelKey } from "./sessions.ts";
3
3
  /** Models and thinking levels as Pi names them, and the settings built on them. */
4
4
 
@@ -1,10 +1,10 @@
1
- import type { AgentTurnScope, TurnSelection } from "../sessions.ts";
2
- import type { Speaker } from "../speakers.ts";
1
+ import type { Speaker } from "../identity/speakers.ts";
3
2
  import type { TurnAttachments } from "./attachment.ts";
4
3
  import type { ClientPort } from "./client.ts";
5
4
  import type { ChannelKey } from "./conversation.ts";
6
5
  import type { InterimPosts } from "./interim.ts";
7
6
  import type { TurnProgress } from "./progress.ts";
7
+ import type { AgentTurnScope, TurnSelection } from "./sessions.ts";
8
8
 
9
9
  export type { AgentTurnScope };
10
10
 
@@ -1,10 +1,10 @@
1
1
  import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
2
- import type { ClientPort } from "./domain/client.ts";
3
- import { PluginError } from "./errors.ts";
4
- import type { Principal } from "./identity/principal-store.ts";
5
- import type { OwnerIdentity } from "./identity.ts";
6
- import type { ApprovedBy } from "./interactions/prompts.ts";
7
- import type { Speaker } from "./speakers.ts";
2
+ import type { OwnerIdentity } from "../identity/owner-identity.ts";
3
+ import type { Principal } from "../identity/principal-store.ts";
4
+ import type { Speaker } from "../identity/speakers.ts";
5
+ import type { ApprovedBy } from "../interactions/prompts.ts";
6
+ import { PluginError } from "../kernel/errors.ts";
7
+ import type { ClientPort } from "./client.ts";
8
8
 
9
9
  /** `<surface>:<channel id>`, for example `discord:1234`. A DM is one channel. */
10
10
  export type ChannelKey = `${string}:${string}`;
@@ -2,51 +2,51 @@ import { readFileSync } from "node:fs";
2
2
  import { userInfo } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { ModelRegistry, ModelRuntime } from "@earendil-works/pi-coding-agent";
5
- import { agentServerPlugin, LOCAL_TEAM_ID } from "./builtin/agent-server.ts";
6
- import { channelContextPlugin } from "./builtin/channel-context.ts";
7
- import { discordPlugin } from "./builtin/discord.ts";
8
- import { discordAdminPlugin } from "./builtin/discord-admin.ts";
9
- import { modulesPlugin, schedulerPlugin } from "./builtin/modules.ts";
10
- import { promptsPlugin } from "./builtin/prompts.ts";
11
- import { seedsPlugin } from "./builtin/seeds.ts";
12
- import { skillsPlugin } from "./builtin/skills.ts";
5
+ import { agentServerPlugin, LOCAL_TEAM_ID } from "../builtin/agent-server.ts";
6
+ import { channelContextPlugin } from "../builtin/channel-context.ts";
7
+ import { discordPlugin } from "../builtin/discord.ts";
8
+ import { discordAdminPlugin } from "../builtin/discord-admin.ts";
9
+ import { identityPlugin } from "../builtin/identity.ts";
10
+ import { modulesPlugin, schedulerPlugin } from "../builtin/modules.ts";
11
+ import { promptsPlugin } from "../builtin/prompts.ts";
12
+ import { seedsPlugin } from "../builtin/seeds.ts";
13
+ import { skillsPlugin } from "../builtin/skills.ts";
13
14
  import {
14
15
  memoryPlugin,
15
16
  precheckPlugin,
16
17
  scheduleStorePlugin,
17
- } from "./builtin/stores.ts";
18
- import { threadsPlugin } from "./builtin/threads.ts";
19
- import { workerSessionsPlugin } from "./builtin/worker-sessions.ts";
20
- import { warnDeprecations } from "./config/access.ts";
18
+ } from "../builtin/stores.ts";
19
+ import { threadsPlugin } from "../builtin/threads.ts";
20
+ import { workerSessionsPlugin } from "../builtin/worker-sessions.ts";
21
+ import { warnDeprecations } from "../config/access.ts";
21
22
  import {
22
23
  type ResolvedConfig,
23
24
  type RoundtableConfig,
24
25
  resolveConfig,
25
- } from "./config/config.ts";
26
- import { conversationsPlugin } from "./conversations/conversations-plugin.ts";
27
- import { ConfigError } from "./domain/errors.ts";
28
- import { JudgeError } from "./errors.ts";
29
- import type { RoundtableOptions } from "./host.ts";
30
- import type { ListenerConfig } from "./http/listeners.ts";
31
- import { identityPlugin } from "./identity/identity-plugin.ts";
32
- import { type JudgeModel, piJudgeModel } from "./judging/model-judge.ts";
33
- import { createLogger, type LogEntry, type Logger } from "./log.ts";
34
- import { formatModelRef, type ModelRef } from "./models.ts";
35
- import { modesPlugin } from "./modes/modes-plugin.ts";
36
- import { ErrorReporter } from "./ops/error-reporter.ts";
37
- import type { RoundtablePlugin } from "./plugin.ts";
26
+ } from "../config/config.ts";
27
+ import { conversationsPlugin } from "../conversations/conversations-plugin.ts";
28
+ import { ConfigError } from "../domain/errors.ts";
29
+ import { formatModelRef, type ModelRef } from "../domain/models.ts";
30
+ import type { ListenerConfig } from "../http/listeners.ts";
31
+ import { type JudgeModel, piJudgeModel } from "../judging/model-judge.ts";
32
+ import { JudgeError } from "../kernel/errors.ts";
33
+ import { createLogger, type LogEntry, type Logger } from "../kernel/log.ts";
34
+ import { modesPlugin } from "../modes/modes-plugin.ts";
35
+ import { ErrorReporter } from "../ops/error-reporter.ts";
36
+ import type { RoundtablePlugin } from "../plugin-api/plugin.ts";
38
37
  import {
39
38
  BRIDGE_MEMORY_FIX,
40
39
  bridgeMemoryProblem,
41
40
  configuredCrowd,
42
41
  onClaudeBridge,
43
- } from "./runtime/bridge-guard.ts";
42
+ } from "../runtime/bridge-guard.ts";
44
43
  import {
45
44
  type AgentSessionsSlot,
46
45
  agentSessionsSlot,
47
46
  runtimePlugin,
48
- } from "./runtime/runtime-plugin.ts";
49
- import { toolTiers } from "./tool-tiers.ts";
47
+ } from "../runtime/runtime-plugin.ts";
48
+ import { toolTiers } from "../runtime/tool-tiers.ts";
49
+ import type { RoundtableOptions } from "./host.ts";
50
50
 
51
51
  /** What `defineRoundtable` returns: give both to `new Roundtable(options, plugins)`. */
52
52
  export interface DefinedRoundtable {
@@ -75,7 +75,7 @@ export interface DefineOverrides {
75
75
  aborted?: (left: string[]) => Promise<void>;
76
76
  }
77
77
 
78
- const ASSETS = join(import.meta.dir, "assets");
78
+ const ASSETS = join(import.meta.dir, "../assets");
79
79
 
80
80
  function readPrompt(path: string, key: string): string {
81
81
  let text: string;
@@ -1,10 +1,5 @@
1
- import type { Logger } from "./log.ts";
2
-
3
- /**
4
- * How long a shutdown waits for running work before aborting it: long enough for a usual turn to
5
- * answer, short enough that a hung one never holds a restart for an hour.
6
- */
7
- export const DRAIN_LIMIT_MS = 3 * 60_000;
1
+ import { DRAIN_LIMIT_MS } from "../config/config-schema.ts";
2
+ import type { Logger } from "../kernel/log.ts";
8
3
 
9
4
  /** How long work that was told to stop gets to end before the shutdown goes on without it. */
10
5
  const ABORT_GRACE_MS = 10_000;
@@ -1,5 +1,5 @@
1
- import type { Logger } from "./log.ts";
2
- import type { EventHandlers, EventSink } from "./plugin.ts";
1
+ import type { Logger } from "../kernel/log.ts";
2
+ import type { EventHandlers, EventSink } from "../plugin-api/plugin.ts";
3
3
 
4
4
  /** One registered plugin's handlers. */
5
5
  interface Registered {
@@ -1,6 +1,6 @@
1
- import type { Logger } from "./log.ts";
2
- import type { ServiceStartedEvent } from "./plugin.ts";
3
- import type { Registry } from "./registry/contributions.ts";
1
+ import type { Logger } from "../kernel/log.ts";
2
+ import type { ServiceStartedEvent } from "../plugin-api/plugin.ts";
3
+ import type { Registry } from "../registry/contributions.ts";
4
4
 
5
5
  type Attempt = { ok: true } | { ok: false; error: unknown };
6
6
 
@@ -4,49 +4,49 @@ import {
4
4
  CharacterError,
5
5
  checkSkins,
6
6
  type Hex,
7
- } from "../characters/index.ts";
8
- import { attachmentPort } from "./attachments/attachment-port.ts";
9
- import { retentionServices } from "./attachments/attachment-retention.ts";
10
- import type { AttachmentPort } from "./contract/attachments.ts";
11
- import type { ConversationPort } from "./contract/channels.ts";
12
- import type { ResolvedProviders } from "./contract/providers.ts";
13
- import type { SurfacePort } from "./contract/surface.ts";
14
- import { ConfigError } from "./domain/errors.ts";
15
- import { NotLinkedError } from "./errors.ts";
16
- import { EventBus } from "./events.ts";
17
- import type { RoundtableOptions } from "./host.ts";
18
- import { HttpListeners, listenerAddress } from "./http/listeners.ts";
19
- import { setLocale } from "./i18n/index.ts";
20
- import { contactsOf } from "./identity/identity-view.ts";
7
+ } from "../../characters/index.ts";
8
+ import { attachmentPort } from "../attachments/attachment-port.ts";
9
+ import { retentionServices } from "../attachments/attachment-retention.ts";
10
+ import type { AttachmentPort } from "../contract/attachments.ts";
11
+ import type { ConversationPort } from "../contract/channels.ts";
12
+ import type { ResolvedProviders } from "../contract/providers.ts";
13
+ import type { SurfacePort } from "../contract/surface.ts";
14
+ import { ConfigError } from "../domain/errors.ts";
15
+ import { HttpListeners, listenerAddress } from "../http/listeners.ts";
16
+ import { setLocale } from "../i18n/index.ts";
17
+ import { contactsOf } from "../identity/identity-view.ts";
18
+ import { NotLinkedError } from "../kernel/errors.ts";
19
+ import { setTimeZone } from "../kernel/time.ts";
21
20
  import type {
22
21
  HostEnv,
23
22
  LinkedSessions,
24
23
  RoundtablePlugin,
25
24
  Service,
26
- } from "./plugin.ts";
27
- import { refuseRemovedFields } from "./plugin.ts";
25
+ } from "../plugin-api/plugin.ts";
26
+ import { refuseRemovedFields } from "../plugin-api/plugin.ts";
27
+ import { CONVERSATIONS, IDENTITY, RUNTIME } from "../plugin-api/services.ts";
28
28
  import {
29
29
  collectContributions,
30
30
  emptyRegistry,
31
31
  linkSessions,
32
32
  type Registry,
33
- } from "./registry/contributions.ts";
34
- import { resolveProviders } from "./registry/providers.ts";
35
- import { replaceServices, ServiceRegistry } from "./registry/services.ts";
36
- import { ChannelQueue } from "./routing/channel-queue.ts";
37
- import { ChannelRouter } from "./routing/channel-router.ts";
33
+ } from "../registry/contributions.ts";
34
+ import { resolveProviders } from "../registry/providers.ts";
35
+ import { replaceServices, ServiceRegistry } from "../registry/services.ts";
36
+ import { ChannelQueue } from "../routing/channel-queue.ts";
37
+ import { ChannelRouter } from "../routing/channel-router.ts";
38
38
  import {
39
39
  type ConversationTurns,
40
40
  conversationTurns,
41
- } from "./routing/conversation-turns.ts";
42
- import { MessageObservers } from "./routing/message-observers.ts";
43
- import { PeerBots } from "./routing/peer-bots.ts";
44
- import { surfacePort } from "./routing/surface-port.ts";
45
- import { refuseHostAccess } from "./runtime/chat-only.ts";
46
- import { CONVERSATIONS, IDENTITY, RUNTIME } from "./services.ts";
47
- import { frozenShellEnv } from "./shared/child-env.ts";
48
- import { setTimeZone } from "./time.ts";
49
- import { type ToolTierTable, toolTiers } from "./tool-tiers.ts";
41
+ } from "../routing/conversation-turns.ts";
42
+ import { MessageObservers } from "../routing/message-observers.ts";
43
+ import { PeerBots } from "../routing/peer-bots.ts";
44
+ import { surfacePort } from "../routing/surface-port.ts";
45
+ import { refuseHostAccess } from "../runtime/chat-only.ts";
46
+ import { type ToolTierTable, toolTiers } from "../runtime/tool-tiers.ts";
47
+ import { frozenShellEnv } from "../shared/child-env.ts";
48
+ import { EventBus } from "./events.ts";
49
+ import type { RoundtableOptions } from "./host.ts";
50
50
 
51
51
  /** The skin tones the host's environment names, checked, or the package's own; a bad set refuses the start. */
52
52
  function characterSkinsOf(skins: readonly Hex[] | undefined): readonly Hex[] {
@@ -1,22 +1,26 @@
1
1
  import type { SQL } from "bun";
2
- import type { Hex } from "../characters/index.ts";
3
- import type { AttachmentRetention } from "./attachments/attachment-retention.ts";
4
- import { checkDatabase } from "./db/check-database.ts";
5
- import { openPool, runMigrations } from "./db/migrations.ts";
2
+ import type { Hex } from "../../characters/index.ts";
3
+ import type { AttachmentRetention } from "../attachments/attachment-retention.ts";
4
+ import type { PeerBotsConfig } from "../config/peer-bots.ts";
5
+ import { checkDatabase } from "../db/check-database.ts";
6
+ import { openPool, runMigrations } from "../db/migrations.ts";
7
+ import type { ChannelKey } from "../domain/sessions.ts";
8
+ import type { HttpListeners, ListenerConfig } from "../http/listeners.ts";
9
+ import type { Locale } from "../i18n/index.ts";
10
+ import type { JudgeModel } from "../judging/model-judge.ts";
11
+ import { MigrationError, PluginError } from "../kernel/errors.ts";
12
+ import type { Logger } from "../kernel/log.ts";
13
+ import type {
14
+ AgentTools,
15
+ RoundtablePlugin,
16
+ Service,
17
+ } from "../plugin-api/plugin.ts";
18
+ import { RUNTIME } from "../plugin-api/services.ts";
19
+ import type { ToolTierTable } from "../runtime/tool-tiers.ts";
20
+ import type { ShellEnvConfig } from "../shared/child-env.ts";
6
21
  import { type DrainOptions, drainWork, stopTurns } from "./drain.ts";
7
- import { MigrationError, PluginError } from "./errors.ts";
8
22
  import { attempt, startInBackground } from "./host-background.ts";
9
23
  import { Linkage, type RegistrationReport } from "./host-registration.ts";
10
- import type { HttpListeners, ListenerConfig } from "./http/listeners.ts";
11
- import type { Locale } from "./i18n/index.ts";
12
- import type { JudgeModel } from "./judging/model-judge.ts";
13
- import type { Logger } from "./log.ts";
14
- import type { AgentTools, RoundtablePlugin, Service } from "./plugin.ts";
15
- import type { PeerBotsConfig } from "./routing/peer-bots.ts";
16
- import { RUNTIME } from "./services.ts";
17
- import type { ChannelKey } from "./sessions.ts";
18
- import type { ShellEnvConfig } from "./shared/child-env.ts";
19
- import type { ToolTierTable } from "./tool-tiers.ts";
20
24
 
21
25
  /**
22
26
  * What differs between hosts: the words and time the process speaks in, and the Pi agent
@@ -1,7 +1,7 @@
1
1
  import { chmodSync } from "node:fs";
2
2
  import type { Server, WebSocketHandler } from "bun";
3
- import { PluginError } from "../errors.ts";
4
- import type { Logger } from "../log.ts";
3
+ import { PluginError } from "../kernel/errors.ts";
4
+ import type { Logger } from "../kernel/log.ts";
5
5
  import { serveUnix } from "../shared/unix-server.ts";
6
6
  import {
7
7
  type Connection,
@@ -1,5 +1,5 @@
1
1
  import type { Server, ServerWebSocket, WebSocketHandler } from "bun";
2
- import type { Logger } from "../log.ts";
2
+ import type { Logger } from "../kernel/log.ts";
3
3
 
4
4
  /**
5
5
  * What became of one `send`: written to the connection, `"queued"` behind a client that reads
@@ -1,13 +1,6 @@
1
1
  import type { Pronouns } from "../config/config.ts";
2
2
  import { ConfigError } from "../domain/errors.ts";
3
- import type { ChannelKey } from "../sessions.ts";
4
- import type {
5
- SpeakerFacts,
6
- SpeakerMap,
7
- SpeakerPolicy,
8
- Tier,
9
- TierMembers,
10
- } from "../speakers.ts";
3
+ import type { ChannelKey } from "../domain/sessions.ts";
11
4
  import {
12
5
  type ActorFacts,
13
6
  identityOf,
@@ -15,6 +8,13 @@ import {
15
8
  surfaceOf,
16
9
  } from "./actor-facts.ts";
17
10
  import { SYSTEM_PRINCIPAL } from "./principal-store.ts";
11
+ import type {
12
+ SpeakerFacts,
13
+ SpeakerMap,
14
+ SpeakerPolicy,
15
+ Tier,
16
+ TierMembers,
17
+ } from "./speakers.ts";
18
18
 
19
19
  /** One owner the configuration names: whom they are, and the identities that are theirs. */
20
20
  export interface AccessOwner {
@@ -1,5 +1,5 @@
1
1
  import { parseChannelKey } from "../contract/surface.ts";
2
- import type { ChannelKey } from "../sessions.ts";
2
+ import type { ChannelKey } from "../domain/sessions.ts";
3
3
  import type { IdentityRef } from "./principal-store.ts";
4
4
 
5
5
  /**