pi-roundtable 0.45.2 → 0.47.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 +56 -0
- package/docs/plugins.md +33 -8
- package/package.json +2 -2
- package/src/characters/catalog.ts +1 -0
- package/src/characters/characters.css +2 -1
- package/src/characters/compose.ts +7 -3
- package/src/characters/css.ts +2 -1
- package/src/characters/index.ts +1 -0
- package/src/characters/parts-face.ts +14 -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 +74 -14
- package/src/core/agents/agent-team.ts +50 -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 +215 -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 +14 -43
- 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 +69 -72
- package/src/core/builtin/discord.ts +60 -8
- package/src/core/builtin/modules.ts +2 -0
- package/src/core/config/agent-team.ts +5 -3
- package/src/core/contract/agent-channels.ts +105 -0
- package/src/core/contract/channels.ts +10 -4
- package/src/core/contract/discord-key.ts +15 -0
- package/src/core/contract/places.ts +28 -3
- package/src/core/db/legacy-channels.ts +31 -0
- package/src/core/db/team-move.ts +2 -2
- package/src/core/discord/agent-dashboard-service.ts +55 -0
- package/src/core/{agents → discord}/agent-dashboard.ts +28 -4
- package/src/core/discord/agent-discord.ts +1 -1
- package/src/core/discord/agent-guild.ts +141 -0
- package/src/core/{agents/team-layout.ts → discord/agent-layout.ts} +15 -31
- package/src/core/discord/agent-places.ts +52 -33
- package/src/core/discord/agent-tools.ts +237 -0
- package/src/core/discord/channel-operations.ts +2 -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 +119 -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/registry/places.ts +31 -1
- 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 +73 -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 +25 -7
- package/templates/adapters/web/package.json.tmpl +1 -1
- package/templates/package.json.tmpl +1 -1
|
@@ -3,6 +3,7 @@ import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { SQL } from "bun";
|
|
6
|
+
import { discordIdOf, discordKey } from "../contract/discord-key.ts";
|
|
6
7
|
import type { PlaceProvider } from "../contract/places.ts";
|
|
7
8
|
import type { ChatSurface } from "../contract/surface.ts";
|
|
8
9
|
import { NO_ATTACHMENTS } from "../domain/attachment.ts";
|
|
@@ -27,14 +28,18 @@ import {
|
|
|
27
28
|
} from "../testing/database.ts";
|
|
28
29
|
import { useTestLocale } from "../testing/locale.ts";
|
|
29
30
|
import { OWNER_SPEAKER, TEST_OWNER } from "../testing/owner.ts";
|
|
30
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
discordTestChannelOps,
|
|
33
|
+
discordTestPlaces,
|
|
34
|
+
testPlacePort,
|
|
35
|
+
} from "../testing/team-places.ts";
|
|
36
|
+
import type { Agent } from "./agent-rules.ts";
|
|
31
37
|
import { PgAgentStore as AgentStore } from "./agent-store.ts";
|
|
32
38
|
import {
|
|
33
|
-
|
|
39
|
+
AgentServerTeam as AgentTeam,
|
|
34
40
|
type AgentTeamOptions,
|
|
35
41
|
} from "./agent-team.ts";
|
|
36
42
|
import { seeds } from "./agent-team-seeds.ts";
|
|
37
|
-
import { discordKey } from "./team-keys.ts";
|
|
38
43
|
import { TeamPlaces } from "./team-places.ts";
|
|
39
44
|
|
|
40
45
|
export const ENTRY = "1000";
|
|
@@ -94,10 +99,10 @@ class FakeSurfaces {
|
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
101
|
|
|
97
|
-
export { FakeChannels } from "
|
|
102
|
+
export { FakeChannels } from "../testing/fake-agent-channels.ts";
|
|
98
103
|
export { FakeRuntime } from "./agent-team-fake-runtime.ts";
|
|
99
104
|
|
|
100
|
-
import { FakeChannels } from "
|
|
105
|
+
import { FakeChannels } from "../testing/fake-agent-channels.ts";
|
|
101
106
|
|
|
102
107
|
import { FakeRuntime } from "./agent-team-fake-runtime.ts";
|
|
103
108
|
|
|
@@ -140,6 +145,7 @@ export const script: {
|
|
|
140
145
|
prompt: PromptSection[];
|
|
141
146
|
/** The tools plugins defined for agents. */
|
|
142
147
|
tools: string[];
|
|
148
|
+
withheld: string[];
|
|
143
149
|
/** The prompt every agent's starts with; read before each turn, so a test may change it. */
|
|
144
150
|
shared: string;
|
|
145
151
|
/** The one a speaker other than the owner gets instead; empty falls back to `shared`. */
|
|
@@ -148,6 +154,7 @@ export const script: {
|
|
|
148
154
|
scores: undefined,
|
|
149
155
|
prompt: [],
|
|
150
156
|
tools: [],
|
|
157
|
+
withheld: [],
|
|
151
158
|
shared: "Shared rules.",
|
|
152
159
|
guest: "",
|
|
153
160
|
};
|
|
@@ -158,6 +165,8 @@ let skillStore: TestStore<SkillStore>;
|
|
|
158
165
|
let skills: SkillRegistry;
|
|
159
166
|
let places: TeamPlaces;
|
|
160
167
|
const stored: PlaceProvider[] = [];
|
|
168
|
+
/** The listeners the stand-in Discord was given for a deleted channel; `deleteChannel` calls them, as the server does. */
|
|
169
|
+
const removedListeners: ((channelId: string) => void)[] = [];
|
|
161
170
|
export const removedSchedules: number[] = [];
|
|
162
171
|
export const stops: string[] = [];
|
|
163
172
|
/** The events the team reported, in order, as `turnStarted infra`, `turnEnded infra ok`, or `changed`. */
|
|
@@ -166,21 +175,32 @@ export const eventLog: string[] = [];
|
|
|
166
175
|
/** What a plugin adds to every agent's tools: a tool of its own and a group of another server's. */
|
|
167
176
|
const PLUGIN_SELECTION = { tools: ["memory_add"], groups: ["workspace"] };
|
|
168
177
|
|
|
178
|
+
/** Whether an action of the agent waits for the owner, in any of its places. */
|
|
179
|
+
function holdsAction(agent: Agent): boolean {
|
|
180
|
+
return places
|
|
181
|
+
.keysOf(agent.name)
|
|
182
|
+
.some((key) => runtime.held.has(places.scopeOf(agent, key).session));
|
|
183
|
+
}
|
|
184
|
+
|
|
169
185
|
/**
|
|
170
186
|
* Waits until every queued channel task has settled, every active agent has its avatar, which
|
|
171
|
-
* startup draws in the background, and every temp knight
|
|
172
|
-
*
|
|
173
|
-
*
|
|
187
|
+
* startup draws in the background, and every temp knight's stamp has caught up with its work (the
|
|
188
|
+
* stamp is written after the turn starts or ends, off the queue): finished, or still working
|
|
189
|
+
* while an action of it is held. A fixed sleep was too short on a slow runner.
|
|
174
190
|
*/
|
|
175
191
|
export async function settle(): Promise<void> {
|
|
176
192
|
const deadline = Date.now() + 10_000;
|
|
177
193
|
const quiet = () =>
|
|
178
194
|
queue.busy().length === 0 &&
|
|
179
195
|
store.agents().every((a) => a.status !== "active" || a.avatarHash) &&
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
196
|
+
store
|
|
197
|
+
.agents()
|
|
198
|
+
.every(
|
|
199
|
+
(a) =>
|
|
200
|
+
!a.parent ||
|
|
201
|
+
a.status !== "active" ||
|
|
202
|
+
(a.finishedAt === undefined) === holdsAction(a),
|
|
203
|
+
);
|
|
184
204
|
while (!quiet() && Date.now() < deadline) await Bun.sleep(5);
|
|
185
205
|
// Work the last task queued is still finishing.
|
|
186
206
|
await Bun.sleep(20);
|
|
@@ -254,13 +274,30 @@ export function useTeamFixture(
|
|
|
254
274
|
if (local) surfaces.rooms = ["app"];
|
|
255
275
|
runtime = new FakeRuntime();
|
|
256
276
|
stored.length = 0;
|
|
277
|
+
removedListeners.length = 0;
|
|
257
278
|
// The host's providers: Discord's channels with a guild, a room on each surface that hosts them, and a test's own.
|
|
258
279
|
places = new TeamPlaces(
|
|
259
280
|
store,
|
|
260
281
|
store.places,
|
|
261
282
|
testPlacePort({
|
|
262
283
|
rooms: () => surfaces.rooms,
|
|
263
|
-
stored: () => [
|
|
284
|
+
stored: () => [
|
|
285
|
+
...(local
|
|
286
|
+
? []
|
|
287
|
+
: [
|
|
288
|
+
discordTestPlaces(TEST_GUILD, {
|
|
289
|
+
channels,
|
|
290
|
+
server: {
|
|
291
|
+
gone: (id) => channels.deleted.has(id),
|
|
292
|
+
foreign: (id) => channels.foreign.has(id),
|
|
293
|
+
fails: (id) => channels.failing.has(id),
|
|
294
|
+
},
|
|
295
|
+
onRemoved: (listener) => removedListeners.push(listener),
|
|
296
|
+
nameOf: (id) => store.placeOwner(discordKey(id))?.name,
|
|
297
|
+
}),
|
|
298
|
+
]),
|
|
299
|
+
...stored,
|
|
300
|
+
],
|
|
264
301
|
// SAFETY: only a derived provider's post reads it, which the team does not use yet.
|
|
265
302
|
surfaces: surfaces as never,
|
|
266
303
|
}),
|
|
@@ -269,6 +306,7 @@ export function useTeamFixture(
|
|
|
269
306
|
script.scores = undefined;
|
|
270
307
|
script.prompt = [];
|
|
271
308
|
script.tools = [];
|
|
309
|
+
script.withheld = [];
|
|
272
310
|
script.shared = "Shared rules.";
|
|
273
311
|
script.guest = "";
|
|
274
312
|
queue = channelQueue();
|
|
@@ -286,7 +324,7 @@ export function useTeamFixture(
|
|
|
286
324
|
teamId: local ? "local" : "1",
|
|
287
325
|
...(local
|
|
288
326
|
? { coordinator: "coordinator" }
|
|
289
|
-
: {
|
|
327
|
+
: { entryChannel: discordKey(ENTRY) }),
|
|
290
328
|
seeds: () => seeds(local ? undefined : ENTRY),
|
|
291
329
|
store,
|
|
292
330
|
surfaces,
|
|
@@ -311,6 +349,7 @@ export function useTeamFixture(
|
|
|
311
349
|
},
|
|
312
350
|
promptSections: () => script.prompt,
|
|
313
351
|
pluginTools: () => script.tools,
|
|
352
|
+
pluginWithheldFromHelpers: () => script.withheld,
|
|
314
353
|
models: {
|
|
315
354
|
defaults: {
|
|
316
355
|
model: "claude-bridge/claude-opus-5-5",
|
|
@@ -338,6 +377,21 @@ export function useTeamFixture(
|
|
|
338
377
|
guestPrompt: () => script.guest,
|
|
339
378
|
skills,
|
|
340
379
|
...(options.helpers !== undefined ? { helpers: options.helpers } : {}),
|
|
380
|
+
// Discord's side of the deprecated `arrange` and `read`, as the host hands it with a guild.
|
|
381
|
+
...(local
|
|
382
|
+
? {}
|
|
383
|
+
: {
|
|
384
|
+
formerChannelOps: () =>
|
|
385
|
+
discordTestChannelOps(channels, {
|
|
386
|
+
agent: (name) => store.agent(name),
|
|
387
|
+
group: (name) => store.group(name),
|
|
388
|
+
ownerOf: (id) => store.placeOwner(discordKey(id))?.name,
|
|
389
|
+
channelOf: (name) => {
|
|
390
|
+
const key = places.placeOn(name, "discord");
|
|
391
|
+
return key === undefined ? undefined : discordIdOf(key);
|
|
392
|
+
},
|
|
393
|
+
}),
|
|
394
|
+
}),
|
|
341
395
|
logger: silentLogger(),
|
|
342
396
|
});
|
|
343
397
|
team = build();
|
|
@@ -358,6 +412,12 @@ export function useTeamFixture(
|
|
|
358
412
|
}, HOOK_TIMEOUT_MS);
|
|
359
413
|
}
|
|
360
414
|
|
|
415
|
+
/** The server deletes a channel and tells the listeners the team registered. */
|
|
416
|
+
export function deleteChannel(channelId: string): void {
|
|
417
|
+
channels.deleted.add(channelId);
|
|
418
|
+
for (const listener of removedListeners) listener(channelId);
|
|
419
|
+
}
|
|
420
|
+
|
|
361
421
|
/** Starts the team again over the same database, as a restarted host: a new queue, runtime and team. */
|
|
362
422
|
/** The identity service the team's replay asks; none until a test sets one. */
|
|
363
423
|
export const identity: { current?: Pick<IdentityService, "speakerFor"> } = {};
|
|
@@ -10,10 +10,11 @@ import type { TurnSelection } from "../domain/sessions.ts";
|
|
|
10
10
|
import { type Speaker, THE_SPEAKER } from "../identity/speakers.ts";
|
|
11
11
|
import type { PromptVersion } from "../modules/prompts/prompt-history.ts";
|
|
12
12
|
import type { ResolvedSkill } from "../modules/skills/skill-rules.ts";
|
|
13
|
+
import type { AgentOps, FormerChannelOps } from "../plugin-api/agent-ops.ts";
|
|
13
14
|
import type { AgentChange, AgentTeam } from "../plugin-api/services.ts";
|
|
14
15
|
import type { Agent } from "./agent-store.ts";
|
|
15
16
|
import {
|
|
16
|
-
type
|
|
17
|
+
type AgentToolOptions,
|
|
17
18
|
type AvatarMode,
|
|
18
19
|
agentToolsExtension,
|
|
19
20
|
} from "./agent-tools.ts";
|
|
@@ -24,23 +25,14 @@ import { type Routes, routesOf } from "./routes.ts";
|
|
|
24
25
|
import { TeamEditing } from "./team-editing.ts";
|
|
25
26
|
import type { TeamHelpers } from "./team-helpers.ts";
|
|
26
27
|
import { coordinatorOf } from "./team-keys.ts";
|
|
27
|
-
import {
|
|
28
|
-
layoutText,
|
|
29
|
-
planArrangement,
|
|
30
|
-
resolveArrangement,
|
|
31
|
-
} from "./team-layout.ts";
|
|
32
28
|
import { TeamLifecycle } from "./team-lifecycle.ts";
|
|
29
|
+
import { TeamLooks } from "./team-looks.ts";
|
|
33
30
|
import type { AgentTeamOptions, TeamContext } from "./team-options.ts";
|
|
34
31
|
import { teamSystemPrompt } from "./team-prompt.ts";
|
|
35
32
|
import { TeamRooms } from "./team-rooms.ts";
|
|
36
33
|
import { teamSelection } from "./team-selection.ts";
|
|
37
34
|
import { type TeamStatus, teamStatus } from "./team-status.ts";
|
|
38
|
-
import {
|
|
39
|
-
agentDetails,
|
|
40
|
-
NO_CHANNELS,
|
|
41
|
-
readChannel,
|
|
42
|
-
teamListText,
|
|
43
|
-
} from "./team-text.ts";
|
|
35
|
+
import { agentDetails, NO_CHANNELS, teamListText } from "./team-text.ts";
|
|
44
36
|
import { TeamTurns } from "./team-turns.ts";
|
|
45
37
|
|
|
46
38
|
export type { AgentTeamOptions } from "./team-options.ts";
|
|
@@ -51,13 +43,14 @@ export type { AgentStatus, GroupStatus, TeamStatus } from "./team-status.ts";
|
|
|
51
43
|
* This team creates, changes, arranges, and archives agents and groups; its TeamTurns runs
|
|
52
44
|
* their turns, group rounds, and messages between agents.
|
|
53
45
|
*/
|
|
54
|
-
export class
|
|
46
|
+
export class AgentServerTeam implements AgentOps, AgentTeam {
|
|
55
47
|
readonly #options: AgentTeamOptions;
|
|
56
48
|
readonly #turns: TeamTurns;
|
|
57
49
|
readonly #listeners: (() => void)[] = [];
|
|
58
50
|
readonly #context: TeamContext;
|
|
59
51
|
readonly #lifecycle: TeamLifecycle;
|
|
60
52
|
readonly #editing: TeamEditing;
|
|
53
|
+
readonly #looks: TeamLooks;
|
|
61
54
|
|
|
62
55
|
constructor(options: AgentTeamOptions) {
|
|
63
56
|
// One routing table for the team's turns and its editing.
|
|
@@ -80,6 +73,7 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
80
73
|
};
|
|
81
74
|
this.#lifecycle = new TeamLifecycle(this.#context);
|
|
82
75
|
this.#editing = new TeamEditing(this.#context);
|
|
76
|
+
this.#looks = new TeamLooks(this.#context);
|
|
83
77
|
}
|
|
84
78
|
|
|
85
79
|
get teamId(): string {
|
|
@@ -91,11 +85,6 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
91
85
|
return this.#options.teamId;
|
|
92
86
|
}
|
|
93
87
|
|
|
94
|
-
/** @deprecated The Discord guild is the Discord place provider's `space`; removed in 1.0. */
|
|
95
|
-
get discordGuild(): string | undefined {
|
|
96
|
-
return this.#options.discordGuild;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
88
|
/** Called when a turn starts or ends and when an agent or group changes. */
|
|
100
89
|
onChange(listener: () => void): void {
|
|
101
90
|
this.#listeners.push(listener);
|
|
@@ -123,7 +112,7 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
123
112
|
|
|
124
113
|
/**
|
|
125
114
|
* Every key an agent or group is addressed by: its place on each provider's surface, in the
|
|
126
|
-
* order "auto" routing prefers (
|
|
115
|
+
* order "auto" routing prefers (a stored place first when it has one); empty for an unknown name.
|
|
127
116
|
*/
|
|
128
117
|
roomsOf(name: string): ChannelKey[] {
|
|
129
118
|
return this.#options.places.keysOf(name);
|
|
@@ -174,11 +163,20 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
174
163
|
extension(scope: AgentTurnScope): ExtensionFactory {
|
|
175
164
|
return agentToolsExtension(this, scope, THE_SPEAKER, {
|
|
176
165
|
skills: this.#options.skills !== undefined,
|
|
177
|
-
|
|
166
|
+
arguments: this.#createArguments(),
|
|
178
167
|
rooms: new TeamRooms(this.#options.store, () => this.#options.rooms?.()),
|
|
179
168
|
});
|
|
180
169
|
}
|
|
181
170
|
|
|
171
|
+
/** What the surfaces' place providers add to the creation tools, merged over the stored providers in contribution order. */
|
|
172
|
+
#createArguments(): NonNullable<AgentToolOptions["arguments"]> {
|
|
173
|
+
const stored = this.#options.places.stored();
|
|
174
|
+
return {
|
|
175
|
+
agent: Object.assign({}, ...stored.map((p) => p.createArguments?.agent)),
|
|
176
|
+
group: Object.assign({}, ...stored.map((p) => p.createArguments?.group)),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
182
180
|
/** The skill files an agent's sessions load, built-in ones included; none while the skills addon is off. */
|
|
183
181
|
skillsOf(name: string): ResolvedSkill[] {
|
|
184
182
|
return this.#options.skills?.carried(name).skills ?? [];
|
|
@@ -233,12 +231,12 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
233
231
|
return this.#lifecycle.startFresh(channel);
|
|
234
232
|
}
|
|
235
233
|
|
|
236
|
-
/** A deleted
|
|
237
|
-
|
|
238
|
-
return this.#lifecycle.
|
|
234
|
+
/** A place deleted on its surface archives the agent or group that owned it. */
|
|
235
|
+
placeRemoved(key: ChannelKey): Promise<void> {
|
|
236
|
+
return this.#lifecycle.placeRemoved(key);
|
|
239
237
|
}
|
|
240
238
|
|
|
241
|
-
/** Archives an agent or group like a deleted
|
|
239
|
+
/** Archives an agent or group like a deleted place, keeping its places where nothing answers. */
|
|
242
240
|
archive(caller: AgentTurnScope | undefined, name: string): Promise<string> {
|
|
243
241
|
return this.#lifecycle.archive(caller, name);
|
|
244
242
|
}
|
|
@@ -316,42 +314,16 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
316
314
|
return this.#lifecycle.helpers.reach(...args);
|
|
317
315
|
}
|
|
318
316
|
|
|
319
|
-
read(...args: [string, string | undefined, number | undefined]) {
|
|
320
|
-
return readChannel(this.#options.channels, ...args);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
317
|
// ── AgentOps ───────────────────────────────────────────────────────────
|
|
324
318
|
|
|
325
319
|
async list(): Promise<string> {
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
return channels
|
|
329
|
-
? `${list}\n\n${layoutText(await channels.layout(), store)}`
|
|
330
|
-
: list;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Sorts agent and group channels into team categories and orders them (spec behavior 57):
|
|
335
|
-
* the listed categories and channels first, everything else after in its current order. A
|
|
336
|
-
* wrong entry refuses the whole call before anything moves.
|
|
337
|
-
*/
|
|
338
|
-
async arrange(
|
|
339
|
-
entries: { category: string; names: string[] }[],
|
|
340
|
-
): Promise<string> {
|
|
341
|
-
const { store, channels, logger } = this.#options;
|
|
342
|
-
if (!channels) throw new AgentError(NO_CHANNELS);
|
|
343
|
-
const listed = resolveArrangement(entries, store);
|
|
344
|
-
const { layout, remove } = planArrangement(listed, await channels.layout());
|
|
345
|
-
await channels.arrange(layout, remove);
|
|
346
|
-
logger.info(
|
|
347
|
-
{ entries: listed.map((l) => l.category), removed: remove.length },
|
|
348
|
-
"agent channels arranged",
|
|
320
|
+
const sections = await Promise.all(
|
|
321
|
+
this.#options.places.stored().map((provider) => provider.layoutText?.()),
|
|
349
322
|
);
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
return `Arranged the channels.${removed}\n\n${layoutText(await channels.layout(), store)}`;
|
|
323
|
+
return [
|
|
324
|
+
teamListText(this.#options.store),
|
|
325
|
+
...sections.filter((text) => text !== undefined),
|
|
326
|
+
].join("\n\n");
|
|
355
327
|
}
|
|
356
328
|
|
|
357
329
|
get(name: string): string {
|
|
@@ -469,17 +441,17 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
469
441
|
|
|
470
442
|
/** Changes an agent's look; see `AgentTeam.dress`. */
|
|
471
443
|
dress(name: string, input: CharacterInput): Promise<Agent> {
|
|
472
|
-
return this.#
|
|
444
|
+
return this.#looks.dress(name, input);
|
|
473
445
|
}
|
|
474
446
|
|
|
475
447
|
/** The agent tool that changes a look; see `AgentTeam.dress`. */
|
|
476
448
|
avatar(name: string, look: CharacterInput): Promise<string> {
|
|
477
|
-
return this.#
|
|
449
|
+
return this.#looks.avatar(name, look);
|
|
478
450
|
}
|
|
479
451
|
|
|
480
452
|
/** @deprecated Use `dress`; removed in 1.0. Draws and stores a new picture. */
|
|
481
453
|
redrawAvatar(name: string, mode: AvatarMode, text?: string): Promise<Agent> {
|
|
482
|
-
return this.#
|
|
454
|
+
return this.#looks.redrawAvatar(name, mode, text);
|
|
483
455
|
}
|
|
484
456
|
|
|
485
457
|
createGroup(
|
|
@@ -494,4 +466,23 @@ export class DiscordAgentTeam implements AgentOps, AgentTeam {
|
|
|
494
466
|
): Promise<string> {
|
|
495
467
|
return this.#editing.updateGroup(name, change);
|
|
496
468
|
}
|
|
469
|
+
|
|
470
|
+
/** The surface's side of `arrange` and `read`, which its own tools took over; refuses without one. */
|
|
471
|
+
#formerChannelOps(): FormerChannelOps {
|
|
472
|
+
const ops = this.#options.formerChannelOps?.();
|
|
473
|
+
if (!ops) throw new AgentError(NO_CHANNELS);
|
|
474
|
+
return ops;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** @deprecated The surface that holds the channels contributes the tool; see `AgentOps.arrange`. Removed in 1.0. */
|
|
478
|
+
async arrange(
|
|
479
|
+
...args: Parameters<FormerChannelOps["arrange"]>
|
|
480
|
+
): Promise<string> {
|
|
481
|
+
return this.#formerChannelOps().arrange(...args);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/** @deprecated The surface that holds the channels contributes the tool; see `AgentOps.read`. Removed in 1.0. */
|
|
485
|
+
async read(...args: Parameters<FormerChannelOps["read"]>): Promise<string> {
|
|
486
|
+
return this.#formerChannelOps().read(...args);
|
|
487
|
+
}
|
|
497
488
|
}
|