pi-roundtable 0.26.2 → 0.27.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 (84) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +23 -0
  3. package/README.zh-TW.md +31 -8
  4. package/docs/plugins.md +176 -7
  5. package/package.json +1 -1
  6. package/src/core/agents/agent-book.ts +34 -1
  7. package/src/core/agents/agent-claim.ts +25 -5
  8. package/src/core/agents/agent-dashboard.ts +23 -2
  9. package/src/core/agents/agent-messages.ts +28 -10
  10. package/src/core/agents/agent-ports.ts +10 -0
  11. package/src/core/agents/agent-prompt.ts +17 -1
  12. package/src/core/agents/agent-rules.ts +11 -1
  13. package/src/core/agents/agent-schema.ts +22 -0
  14. package/src/core/agents/agent-statements.ts +16 -2
  15. package/src/core/agents/agent-store.ts +30 -20
  16. package/src/core/agents/agent-team-fake-runtime.ts +48 -0
  17. package/src/core/agents/agent-team-fixture.ts +32 -44
  18. package/src/core/agents/agent-team.ts +69 -74
  19. package/src/core/agents/agent-tool-schema.ts +84 -0
  20. package/src/core/agents/agent-tools.ts +50 -85
  21. package/src/core/agents/group-turns.ts +132 -41
  22. package/src/core/agents/helper-create.ts +180 -0
  23. package/src/core/agents/helper-ops.ts +33 -0
  24. package/src/core/agents/helper-test-kit.ts +72 -0
  25. package/src/core/agents/helper-tools.ts +104 -0
  26. package/src/core/agents/helper-work.ts +101 -0
  27. package/src/core/agents/message-target.ts +15 -23
  28. package/src/core/agents/routes.ts +347 -0
  29. package/src/core/agents/team-approval.ts +32 -0
  30. package/src/core/agents/team-editing.ts +97 -32
  31. package/src/core/agents/team-helpers.ts +216 -0
  32. package/src/core/agents/team-lifecycle.ts +26 -1
  33. package/src/core/agents/team-options.ts +8 -0
  34. package/src/core/agents/team-prompt.ts +75 -0
  35. package/src/core/agents/team-selection.ts +31 -13
  36. package/src/core/agents/team-status.ts +6 -0
  37. package/src/core/agents/team-text.ts +20 -4
  38. package/src/core/agents/team-turn-types.ts +12 -1
  39. package/src/core/agents/team-turns.ts +25 -31
  40. package/src/core/builtin/agent-server.ts +37 -2
  41. package/src/core/builtin/modules.ts +4 -4
  42. package/src/core/config/adapters.ts +12 -0
  43. package/src/core/config/agent-team.ts +2 -0
  44. package/src/core/config/config-schema.ts +4 -0
  45. package/src/core/config/config.ts +48 -2
  46. package/src/core/config/helpers.ts +60 -0
  47. package/src/core/config/ops.ts +8 -0
  48. package/src/core/config/routing.ts +296 -0
  49. package/src/core/contract/channels.ts +73 -2
  50. package/src/core/contract/surface.ts +31 -1
  51. package/src/core/define-roundtable.ts +8 -1
  52. package/src/core/discord/agent-discord.ts +67 -6
  53. package/src/core/discord/discord-surface.ts +14 -16
  54. package/src/core/discord/message-changes.ts +66 -0
  55. package/src/core/discord/poster/poster-checks.ts +62 -8
  56. package/src/core/discord/poster/poster.ts +41 -0
  57. package/src/core/discord/poster/rest-poster-read.ts +130 -0
  58. package/src/core/discord/poster/rest-poster.ts +38 -120
  59. package/src/core/domain/round.ts +31 -0
  60. package/src/core/host-registration.ts +15 -0
  61. package/src/core/host.ts +6 -0
  62. package/src/core/i18n/conversation.ts +3 -0
  63. package/src/core/i18n/dashboard.ts +4 -0
  64. package/src/core/ops/error-reporter.ts +4 -0
  65. package/src/core/ops/ops-alerts.ts +102 -6
  66. package/src/core/plugin.ts +17 -0
  67. package/src/core/registry/contributions.ts +1 -26
  68. package/src/core/registry/surface-service.ts +41 -0
  69. package/src/core/routing/channel-router.ts +54 -3
  70. package/src/core/routing/claim-events.ts +42 -0
  71. package/src/core/routing/message-observers.ts +86 -0
  72. package/src/core/routing/peer-bots.ts +149 -0
  73. package/src/core/routing/surface-port.ts +4 -0
  74. package/src/core/services.ts +7 -6
  75. package/src/core/testing/fake-poster-guild.ts +1 -1
  76. package/src/core/testing/fake-poster-reads.ts +96 -0
  77. package/src/core/testing/fake-poster.ts +62 -94
  78. package/src/core/tool-set.snapshot.json +8 -0
  79. package/src/discord/index.ts +2 -0
  80. package/src/index.ts +18 -1
  81. package/src/kit/channels.ts +1 -0
  82. package/src/kit/index.ts +5 -0
  83. package/src/kit/ops-alerts.ts +4 -0
  84. package/src/testing.ts +18 -1
package/src/testing.ts CHANGED
@@ -68,6 +68,8 @@ import {
68
68
  type ConversationTurns,
69
69
  conversationTurns,
70
70
  } from "./core/routing/conversation-turns.ts";
71
+ import { MessageObservers } from "./core/routing/message-observers.ts";
72
+ import { PeerBots, type PeerBotsConfig } from "./core/routing/peer-bots.ts";
71
73
  import { surfacePort } from "./core/routing/surface-port.ts";
72
74
  import {
73
75
  AGENTS,
@@ -258,6 +260,8 @@ export interface TestPluginOptions {
258
260
  apiKeys?: Readonly<Record<string, string>>;
259
261
  /** How long the router holds a bare forward for the message that follows it; the host option `conversations.forwardJoinMs`. */
260
262
  forwardJoinMs?: number;
263
+ /** The peer bots the router answers, as the host option `peerBots` (`discord.peerBots`); default none. */
264
+ peerBots?: PeerBotsConfig;
261
265
  /** The addresses `context.listener(id)` reports; a plugin that reads one gets `undefined` for any not listed. */
262
266
  listeners?: readonly ListenerConfig[];
263
267
  }
@@ -384,6 +388,10 @@ export async function testPlugin(
384
388
  const conversations: ConversationPort = {
385
389
  handle: async (message) =>
386
390
  (router ?? unlinked("conversations")).handle(message),
391
+ messageDeleted: async (channel, id, space) =>
392
+ (router ?? unlinked("conversations")).messageDeleted(channel, id, space),
393
+ messageEdited: async (message) =>
394
+ (router ?? unlinked("conversations")).messageEdited(message),
387
395
  background: async (turn) =>
388
396
  (router ?? unlinked("conversations")).background(turn),
389
397
  runsAs: async (turn) => (router ?? unlinked("conversations")).runsAs(turn),
@@ -407,6 +415,7 @@ export async function testPlugin(
407
415
  ? [...registry.surfaces, ...(options.surfaces ?? [])]
408
416
  : unlinked("surfaces"),
409
417
  );
418
+ const observers = new MessageObservers(logger, () => surfaces.roomSurfaces());
410
419
  const sink = {
411
420
  turnStarted: (turn: TurnEvent) => {
412
421
  events.push({ name: "turnStarted", turn });
@@ -538,6 +547,7 @@ export async function testPlugin(
538
547
  }),
539
548
  surfaces,
540
549
  turns,
550
+ observe: (filter, observer) => observers.add(filter, observer),
541
551
  database: () => {
542
552
  if (!options.database) throw new PluginError("no database is configured");
543
553
  return options.database;
@@ -602,6 +612,8 @@ export async function testPlugin(
602
612
  : undefined),
603
613
  queue,
604
614
  logger,
615
+ observers,
616
+ ...(options.peerBots ? { peerBots: new PeerBots(options.peerBots) } : {}),
605
617
  ...(options.forwardJoinMs === undefined
606
618
  ? {}
607
619
  : { forwardJoinMs: options.forwardJoinMs }),
@@ -640,7 +652,12 @@ export async function testPlugin(
640
652
  throw error;
641
653
  }
642
654
  for (const service of registry.services) await service.start?.();
643
- for (const surface of options.surfaces ?? []) await surface.start(deliver);
655
+ for (const surface of options.surfaces ?? [])
656
+ await surface.start(deliver, {
657
+ deleted: (channel, id, space) =>
658
+ void conversations.messageDeleted?.(channel, id, space),
659
+ edited: (message) => void conversations.messageEdited?.(message),
660
+ });
644
661
  let stopped = false;
645
662
  const files: { channel: ChannelKey; file: ReplyFile }[] = [];
646
663
  const images: { channel: ChannelKey; image: ClientPart }[] = [];