pi-roundtable 0.45.1 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/docs/plugins.md +32 -7
- package/package.json +1 -1
- package/src/characters/compose.ts +7 -3
- package/src/characters/index.ts +1 -0
- package/src/characters/parts-face.ts +4 -1
- package/src/core/agents/agent-claim.ts +2 -2
- package/src/core/agents/agent-group-store.ts +74 -1
- package/src/core/agents/agent-places.ts +32 -0
- package/src/core/agents/agent-ports.ts +0 -94
- package/src/core/agents/agent-prompt.ts +3 -1
- package/src/core/agents/agent-team-fixture.ts +48 -7
- package/src/core/agents/agent-team.ts +54 -59
- package/src/core/agents/agent-tools.ts +34 -166
- package/src/core/agents/message-target.ts +3 -2
- package/src/core/agents/routes.ts +2 -1
- package/src/core/agents/team-editing.ts +121 -150
- package/src/core/agents/team-helpers.ts +80 -59
- package/src/core/agents/team-keys.ts +16 -26
- package/src/core/agents/team-lifecycle.ts +155 -99
- package/src/core/agents/team-looks.ts +102 -0
- package/src/core/agents/team-options.ts +12 -11
- package/src/core/agents/team-place-writes.ts +193 -0
- package/src/core/agents/team-places.ts +30 -0
- package/src/core/agents/team-posts.ts +42 -73
- package/src/core/agents/team-selection.ts +10 -2
- package/src/core/agents/team-status.ts +3 -2
- package/src/core/agents/team-text.ts +13 -46
- package/src/core/agents/team-turn-types.ts +11 -16
- package/src/core/agents/team-turns.ts +7 -6
- package/src/core/builtin/agent-server-options.ts +27 -6
- package/src/core/builtin/agent-server.ts +65 -69
- package/src/core/builtin/discord.ts +58 -8
- package/src/core/builtin/modules.ts +2 -0
- package/src/core/contract/agent-channels.ts +97 -0
- package/src/core/contract/channels.ts +10 -4
- package/src/core/contract/discord-key.ts +15 -0
- package/src/core/contract/places.ts +8 -2
- package/src/core/db/legacy-channels.ts +31 -0
- package/src/core/discord/agent-dashboard-service.ts +55 -0
- package/src/core/{agents → discord}/agent-dashboard.ts +7 -2
- package/src/core/discord/agent-discord.ts +1 -1
- package/src/core/discord/agent-guild.ts +87 -0
- package/src/core/{agents/team-layout.ts → discord/agent-layout.ts} +9 -29
- package/src/core/discord/agent-places.ts +52 -33
- package/src/core/discord/agent-tools.ts +210 -0
- package/src/core/discord/connection.ts +4 -1
- package/src/core/discord/discord-surface.ts +9 -14
- package/src/core/discord/place-fake-client.ts +59 -0
- package/src/core/host/define-roundtable.ts +7 -5
- package/src/core/modules/delegation/delegator.ts +5 -0
- package/src/core/plugin-api/agent-ops.ts +123 -0
- package/src/core/plugin-api/agent-server-ids.ts +9 -0
- package/src/core/plugin-api/define.ts +9 -0
- package/src/core/plugin-api/plugin.ts +2 -0
- package/src/core/plugin-api/services.ts +6 -0
- package/src/core/registry/contributions.ts +3 -0
- package/src/core/routing/channel-queue.ts +28 -12
- package/src/core/runtime/pi-agent-runtime.ts +1 -1
- package/src/core/runtime/runtime-plugin.ts +1 -0
- package/src/core/runtime/runtime-types.ts +6 -0
- package/src/core/{agents/agent-team-fake-channels.ts → testing/fake-agent-channels.ts} +5 -1
- package/src/core/testing/fake-pager-places.ts +16 -2
- package/src/core/testing/modules.ts +2 -1
- package/src/core/testing/place-contract.ts +3 -2
- package/src/core/testing/team-places.ts +75 -7
- package/src/core/testing/test-host.ts +20 -16
- package/src/discord/index.ts +5 -0
- package/src/kit/channels.ts +1 -2
- package/src/kit/support.ts +9 -5
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { StoredPlace } from "../agents/agent-places.ts";
|
|
2
2
|
import { type StoredPlaces, TeamPlaces } from "../agents/team-places.ts";
|
|
3
|
+
import type { AgentChannels } from "../contract/agent-channels.ts";
|
|
3
4
|
import type { PlacePort, PlaceProvider } from "../contract/places.ts";
|
|
4
5
|
import type { SurfacePort } from "../contract/surface.ts";
|
|
5
6
|
import { discordPlaces } from "../discord/agent-places.ts";
|
|
7
|
+
import {
|
|
8
|
+
type DiscordAgentToolsOptions,
|
|
9
|
+
discordChannelOps,
|
|
10
|
+
} from "../discord/agent-tools.ts";
|
|
11
|
+
import {
|
|
12
|
+
type FakeServer,
|
|
13
|
+
fakeDiscordClient,
|
|
14
|
+
} from "../discord/place-fake-client.ts";
|
|
6
15
|
import { silentLogger } from "../kernel/log.ts";
|
|
16
|
+
import type { FormerChannelOps } from "../plugin-api/agent-ops.ts";
|
|
7
17
|
import { derivedPlaces } from "../registry/place-port.ts";
|
|
8
18
|
|
|
9
19
|
/** The surface of the legacy channel columns: what a store's `channelId` is a place on. */
|
|
@@ -51,14 +61,52 @@ export function legacyRows(
|
|
|
51
61
|
];
|
|
52
62
|
}
|
|
53
63
|
|
|
54
|
-
/**
|
|
55
|
-
export
|
|
64
|
+
/** The guild the stand-in Discord's agent channels live in. */
|
|
65
|
+
export const TEST_AGENT_GUILD = "900000000000000001";
|
|
66
|
+
|
|
67
|
+
/** What a stand-in Discord's provider asks of the server it stands on. */
|
|
68
|
+
export interface TestDiscord {
|
|
69
|
+
/** The agent channels the provider makes and moves; absent = a provider that is only read. */
|
|
70
|
+
channels?: AgentChannels;
|
|
71
|
+
/** Answers the provider's `check`, as the server does; absent = no `check`. */
|
|
72
|
+
server?: Omit<FakeServer, "guild">;
|
|
73
|
+
/** Where the provider registers the listener of a deleted channel. */
|
|
74
|
+
onRemoved?: (listener: (channelId: string) => void) => void;
|
|
75
|
+
/** The agent or group whose channel it is, for the category listing; absent = a mention. */
|
|
76
|
+
nameOf?: (channelId: string) => string | undefined;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Discord's own provider, with the keys and forms a host gives it, over the channels and server a
|
|
81
|
+
* test hands; without them it only reads places.
|
|
82
|
+
*/
|
|
83
|
+
export function discordTestPlaces(
|
|
84
|
+
guild = TEST_AGENT_GUILD,
|
|
85
|
+
over: TestDiscord = {},
|
|
86
|
+
): PlaceProvider {
|
|
56
87
|
return discordPlaces({
|
|
57
88
|
// SAFETY: a provider that is only read never asks the client or the channels.
|
|
58
|
-
client:
|
|
89
|
+
client: over.server
|
|
90
|
+
? fakeDiscordClient({ guild, ...over.server })
|
|
91
|
+
: (undefined as never),
|
|
59
92
|
guild,
|
|
60
|
-
channels: undefined as never,
|
|
61
|
-
onRemoved: () => undefined,
|
|
93
|
+
channels: over.channels ?? (undefined as never),
|
|
94
|
+
onRemoved: over.onRemoved ?? (() => undefined),
|
|
95
|
+
...(over.nameOf ? { nameOf: over.nameOf } : {}),
|
|
96
|
+
logger: silentLogger(),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Discord's side of the team's deprecated `arrange` and `read`, as a host hands it with a guild. */
|
|
101
|
+
export function discordTestChannelOps(
|
|
102
|
+
channels: AgentChannels,
|
|
103
|
+
directory: DiscordAgentToolsOptions["directory"] extends () => infer D
|
|
104
|
+
? NonNullable<D>
|
|
105
|
+
: never,
|
|
106
|
+
): FormerChannelOps {
|
|
107
|
+
return discordChannelOps({
|
|
108
|
+
channels,
|
|
109
|
+
directory: () => directory,
|
|
62
110
|
logger: silentLogger(),
|
|
63
111
|
});
|
|
64
112
|
}
|
|
@@ -95,20 +143,40 @@ export function testPlacePort(options: {
|
|
|
95
143
|
};
|
|
96
144
|
}
|
|
97
145
|
|
|
98
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* The places of a team over fakes: Discord's provider when `discord` (over `channels`, which it
|
|
148
|
+
* posts through), a room on each of `rooms` (posting through `surfaces`), and `stored` rows.
|
|
149
|
+
*/
|
|
99
150
|
export function testPlaces(options: {
|
|
100
151
|
store: ConstructorParameters<typeof TeamPlaces>[0];
|
|
101
152
|
rows?: () => readonly StoredPlace[];
|
|
102
153
|
rooms?: () => readonly string[];
|
|
103
154
|
discord?: boolean;
|
|
155
|
+
/** The channels Discord's provider posts through; absent = it only reads places. */
|
|
156
|
+
channels?: Partial<AgentChannels>;
|
|
157
|
+
/** What the rooms' derived providers post through; absent = a post fails. */
|
|
158
|
+
surfaces?: Partial<SurfacePort>;
|
|
104
159
|
stored?: () => readonly PlaceProvider[];
|
|
105
160
|
}): TeamPlaces {
|
|
106
|
-
const discord =
|
|
161
|
+
const discord =
|
|
162
|
+
options.discord === false
|
|
163
|
+
? []
|
|
164
|
+
: [
|
|
165
|
+
discordTestPlaces(
|
|
166
|
+
TEST_AGENT_GUILD,
|
|
167
|
+
options.channels
|
|
168
|
+
? { channels: options.channels as AgentChannels }
|
|
169
|
+
: {},
|
|
170
|
+
),
|
|
171
|
+
];
|
|
107
172
|
return new TeamPlaces(
|
|
108
173
|
options.store,
|
|
109
174
|
storedFrom(options.rows ?? (() => [])),
|
|
110
175
|
testPlacePort({
|
|
111
176
|
...(options.rooms ? { rooms: options.rooms } : {}),
|
|
177
|
+
...(options.surfaces
|
|
178
|
+
? { surfaces: options.surfaces as SurfacePort }
|
|
179
|
+
: {}),
|
|
112
180
|
stored: () => [...discord, ...(options.stored?.() ?? [])],
|
|
113
181
|
}),
|
|
114
182
|
);
|
|
@@ -11,7 +11,7 @@ import { type RoundtableConfig, resolveConfig } from "../config/config.ts";
|
|
|
11
11
|
import type { ConversationPort } from "../contract/channels.ts";
|
|
12
12
|
import type { AgentRuntime } from "../contract/runtime.ts";
|
|
13
13
|
import type { ChatSurface } from "../contract/surface.ts";
|
|
14
|
-
import {
|
|
14
|
+
import { discordAgentGuild } from "../discord/agent-guild.ts";
|
|
15
15
|
import { CommandCollection } from "../discord/command-collection.ts";
|
|
16
16
|
import type { ComposedCommands } from "../discord/compose-commands.ts";
|
|
17
17
|
import type { DiscordConnection } from "../discord/connection.ts";
|
|
@@ -186,17 +186,21 @@ export function standInDiscord(
|
|
|
186
186
|
channelContext: DiscordServices["channelContext"] = async () => undefined,
|
|
187
187
|
/** The agent guild, which makes the stand-in contribute Discord's place provider over `agentChannels`, as the built-in plugin does with one. */
|
|
188
188
|
agentGuild?: string,
|
|
189
|
+
/** The channel the coordinator lives in, as the built-in plugin gives it with an agent guild. */
|
|
190
|
+
entryChannel?: string,
|
|
189
191
|
): RoundtablePlugin {
|
|
190
192
|
const surface: ChatSurface = {
|
|
191
193
|
surface: "discord",
|
|
192
194
|
start: async () => undefined,
|
|
193
195
|
sendReply: async () => undefined,
|
|
196
|
+
// What the agents' claim reads through `CHANNEL_CONTEXT`, as the Discord surface answers it.
|
|
197
|
+
channelContext: (message, options) => channelContext(message, options),
|
|
194
198
|
};
|
|
195
199
|
return {
|
|
196
200
|
name: "test-discord",
|
|
197
201
|
provides: [DISCORD],
|
|
198
202
|
replaces: [DISCORD],
|
|
199
|
-
setup: ({ services }) => {
|
|
203
|
+
setup: ({ services, dashboard }) => {
|
|
200
204
|
const identity = services.find(IDENTITY);
|
|
201
205
|
const { poster, ...overrides } = given ?? {};
|
|
202
206
|
const ownerChannel =
|
|
@@ -226,20 +230,19 @@ export function standInDiscord(
|
|
|
226
230
|
poster: poster ?? fakeDiscordPoster(),
|
|
227
231
|
channelContext,
|
|
228
232
|
} as unknown as DiscordServices);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
};
|
|
233
|
+
// Discord's side of the agent guild, as the built-in plugin contributes it with one, over a board that shows nothing.
|
|
234
|
+
const guild = agentGuild
|
|
235
|
+
? discordAgentGuild(
|
|
236
|
+
{ services, dashboard, logger: silentLogger() },
|
|
237
|
+
{
|
|
238
|
+
guild: agentGuild,
|
|
239
|
+
...(entryChannel === undefined ? {} : { entryChannel }),
|
|
240
|
+
// SAFETY: a stand-in's provider is read for keys, and a test host does not run the tools; nothing asks the channels.
|
|
241
|
+
connection: connection as never,
|
|
242
|
+
},
|
|
243
|
+
)
|
|
244
|
+
: undefined;
|
|
245
|
+
return { ...guild, surfaces: [surface], directChannels: [direct] };
|
|
243
246
|
},
|
|
244
247
|
};
|
|
245
248
|
}
|
|
@@ -307,6 +310,7 @@ export async function testHost(
|
|
|
307
310
|
discordOwnerOf(resolved).id,
|
|
308
311
|
undefined,
|
|
309
312
|
resolved.discord?.guild,
|
|
313
|
+
resolved.discord?.entryChannel,
|
|
310
314
|
),
|
|
311
315
|
]
|
|
312
316
|
: []),
|
package/src/discord/index.ts
CHANGED
|
@@ -16,6 +16,11 @@ export {
|
|
|
16
16
|
withChannelContextImages,
|
|
17
17
|
} from "../core/contract/channel-context.ts";
|
|
18
18
|
export type { AgentPanelMessage } from "../core/discord/agent-commands.ts";
|
|
19
|
+
export type {
|
|
20
|
+
DiscordAgentGuild,
|
|
21
|
+
DiscordAgentGuildOptions,
|
|
22
|
+
} from "../core/discord/agent-guild.ts";
|
|
23
|
+
export { discordAgentGuild } from "../core/discord/agent-guild.ts";
|
|
19
24
|
export type {
|
|
20
25
|
AgentPanel,
|
|
21
26
|
AgentPanelOptions,
|
package/src/kit/channels.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// Plugin helpers, versioned like the main entry; see the plugin guide.
|
|
2
2
|
|
|
3
|
-
export { discordKey } from "../core/agents/team-keys.ts";
|
|
4
|
-
|
|
5
3
|
export {
|
|
6
4
|
channelSegment,
|
|
7
5
|
ownerAttachmentDir,
|
|
@@ -15,6 +13,7 @@ export {
|
|
|
15
13
|
squarePng,
|
|
16
14
|
} from "../core/attachments/square-png.ts";
|
|
17
15
|
export { attachmentsOf } from "../core/attachments/turn-attachments.ts";
|
|
16
|
+
export { discordKey } from "../core/contract/discord-key.ts";
|
|
18
17
|
export type { ChannelQueue } from "../core/routing/channel-queue.ts";
|
|
19
18
|
export { channelQueue } from "../core/routing/channel-queue.ts";
|
|
20
19
|
export { withReference } from "../core/routing/message-text.ts";
|
package/src/kit/support.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
// Supporting data types for the service and helper contracts.
|
|
2
2
|
|
|
3
|
+
export type {
|
|
4
|
+
AgentModels,
|
|
5
|
+
AgentTurnRunner,
|
|
6
|
+
} from "../core/agents/agent-ports.ts";
|
|
7
|
+
export type { Backlog, GroupMessage } from "../core/agents/agent-rules.ts";
|
|
8
|
+
// Deprecated here, removed from `pi-roundtable/kit` in 1.0: Discord's agent guild internals,
|
|
9
|
+
// which `pi-roundtable/discord` exports too.
|
|
3
10
|
export type {
|
|
4
11
|
AgentCategory,
|
|
5
12
|
AgentChannels,
|
|
6
|
-
AgentModels,
|
|
7
13
|
AgentPost,
|
|
8
|
-
AgentTurnRunner,
|
|
9
14
|
CategoryLayout,
|
|
10
15
|
ChannelMessage,
|
|
11
16
|
DashboardBoard,
|
|
12
|
-
} from "../core/
|
|
13
|
-
export type { Backlog, GroupMessage } from "../core/agents/agent-rules.ts";
|
|
14
|
-
export type { AgentOps } from "../core/agents/agent-tools.ts";
|
|
17
|
+
} from "../core/contract/agent-channels.ts";
|
|
15
18
|
export type {
|
|
16
19
|
EffortPolicy,
|
|
17
20
|
EffortRequest,
|
|
@@ -22,5 +25,6 @@ export type { Notifier, OwnerNotifier } from "../core/domain/ports.ts";
|
|
|
22
25
|
export type { SpeakerFacts, SpeakerPolicy } from "../core/identity/speakers.ts";
|
|
23
26
|
export type { DelegationWorker } from "../core/modules/delegation/delegator.ts";
|
|
24
27
|
export type { AgentChannelLookup } from "../core/modules/schedules/schedules.ts";
|
|
28
|
+
export type { AgentOps } from "../core/plugin-api/agent-ops.ts";
|
|
25
29
|
export type { AssistantLike } from "../core/shared/session-messages.ts";
|
|
26
30
|
export type { ThreadHost } from "../core/threads/dispatch-threads.ts";
|