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
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
CREATION_TOOL_ARGUMENTS,
|
|
3
|
+
type PlaceProvider,
|
|
4
|
+
} from "../contract/places.ts";
|
|
2
5
|
import type { ChatSurface } from "../contract/surface.ts";
|
|
3
6
|
import { PluginError } from "../kernel/errors.ts";
|
|
4
7
|
|
|
@@ -8,6 +11,11 @@ import { PluginError } from "../kernel/errors.ts";
|
|
|
8
11
|
*/
|
|
9
12
|
export class PlaceClaims {
|
|
10
13
|
readonly #owners = new Map<string, string>();
|
|
14
|
+
/** The plugin that added each creation-tool argument, by tool. */
|
|
15
|
+
readonly #arguments = {
|
|
16
|
+
agent: new Map<string, string>(),
|
|
17
|
+
group: new Map<string, string>(),
|
|
18
|
+
};
|
|
11
19
|
|
|
12
20
|
claim(plugin: string, provider: PlaceProvider): void {
|
|
13
21
|
const { surface } = provider;
|
|
@@ -29,9 +37,31 @@ export class PlaceClaims {
|
|
|
29
37
|
throw new PluginError(
|
|
30
38
|
`plugin ${plugin}: surface ${surface} already has the place provider of plugin ${other}. Keep one provider per surface.`,
|
|
31
39
|
);
|
|
40
|
+
this.#claimArguments(plugin, provider);
|
|
32
41
|
this.#owners.set(surface, plugin);
|
|
33
42
|
}
|
|
34
43
|
|
|
44
|
+
/** Refuses an argument a provider adds to a creation tool that the tool takes itself or another provider adds. */
|
|
45
|
+
#claimArguments(plugin: string, provider: PlaceProvider): void {
|
|
46
|
+
for (const tool of ["agent", "group"] as const) {
|
|
47
|
+
const added = this.#arguments[tool];
|
|
48
|
+
const own: readonly string[] = CREATION_TOOL_ARGUMENTS[tool];
|
|
49
|
+
for (const name of Object.keys(provider.createArguments?.[tool] ?? {})) {
|
|
50
|
+
const where = `plugin ${plugin}: the place provider of surface ${provider.surface} adds the argument ${name} to ${tool}_create`;
|
|
51
|
+
if (own.includes(name))
|
|
52
|
+
throw new PluginError(
|
|
53
|
+
`${where}, which the tool takes itself. Name it otherwise.`,
|
|
54
|
+
);
|
|
55
|
+
const other = added.get(name);
|
|
56
|
+
if (other !== undefined)
|
|
57
|
+
throw new PluginError(
|
|
58
|
+
`${where}, which the place provider of plugin ${other} adds already. Name it otherwise.`,
|
|
59
|
+
);
|
|
60
|
+
added.set(name, plugin);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
35
65
|
/** Refuses a provider whose surface no plugin registered, once every plugin is set up. */
|
|
36
66
|
check(surfaces: readonly ChatSurface[]): void {
|
|
37
67
|
for (const [surface, plugin] of this.#owners)
|
|
@@ -7,8 +7,11 @@ export class ChannelQueue {
|
|
|
7
7
|
readonly #tails = new Map<ChannelKey, Promise<unknown>>();
|
|
8
8
|
readonly #sizes = new Map<ChannelKey, number>();
|
|
9
9
|
readonly #listeners: ((channel: ChannelKey) => void)[] = [];
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Set inside `finishing`, so what a delivery starts and awaits sees the queue as open: 0 in the
|
|
12
|
+
* delivery itself, 1 in the queue task it started, which starts no queue task of its own.
|
|
13
|
+
*/
|
|
14
|
+
readonly #finishing = new AsyncLocalStorage<0 | 1>();
|
|
12
15
|
#closed = false;
|
|
13
16
|
#sealed = false;
|
|
14
17
|
|
|
@@ -26,11 +29,22 @@ export class ChannelQueue {
|
|
|
26
29
|
* `finishing` until the queue is sealed.
|
|
27
30
|
*/
|
|
28
31
|
get closed(): boolean {
|
|
29
|
-
return
|
|
32
|
+
return (
|
|
33
|
+
this.#closed && (this.#sealed || this.#finishing.getStore() === undefined)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Whether the host is shutting down, whatever the scope: unlike `closed`, `finishing` does not
|
|
39
|
+
* mask it, so work that a delivery's own turn spawns, such as a transient task, reads it true.
|
|
40
|
+
*/
|
|
41
|
+
get draining(): boolean {
|
|
42
|
+
return this.#closed;
|
|
30
43
|
}
|
|
31
44
|
|
|
45
|
+
/** Whether a queue task started here is admitted: the delivery's own, not one that task spawns. */
|
|
32
46
|
#admitted(): boolean {
|
|
33
|
-
return !this.#sealed && this.#finishing.getStore() ===
|
|
47
|
+
return !this.#sealed && this.#finishing.getStore() === 0;
|
|
34
48
|
}
|
|
35
49
|
|
|
36
50
|
/**
|
|
@@ -52,20 +66,22 @@ export class ChannelQueue {
|
|
|
52
66
|
|
|
53
67
|
/**
|
|
54
68
|
* Runs `task` as the delivery of work the shutdown drain waits for, such as the report of a
|
|
55
|
-
* task that was running when the host began to stop. A queue task started inside it
|
|
56
|
-
*
|
|
57
|
-
*
|
|
69
|
+
* task that was running when the host began to stop. A queue task started inside it runs
|
|
70
|
+
* although the queue is closed, with `closed` reading false, until the drain ends; a queue
|
|
71
|
+
* task that task starts in turn is refused, as is anything else the shutdown refuses
|
|
72
|
+
* (`draining`, which stays true there). Outside a shutdown it changes nothing.
|
|
58
73
|
*/
|
|
59
74
|
finishing<T>(task: () => Promise<T>): Promise<T> {
|
|
60
|
-
return this.#finishing.run(
|
|
75
|
+
return this.#finishing.run(0, task);
|
|
61
76
|
}
|
|
62
77
|
|
|
63
78
|
run<T>(channel: ChannelKey, task: () => Promise<T>): Promise<T> {
|
|
64
79
|
const admitted = this.#admitted();
|
|
65
|
-
const start = () =>
|
|
66
|
-
this.#closed && !(admitted && !this.#sealed)
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
const start = () => {
|
|
81
|
+
if (this.#closed && !(admitted && !this.#sealed))
|
|
82
|
+
return Promise.reject(new HostStoppingError());
|
|
83
|
+
return admitted ? this.#finishing.run(1, task) : task();
|
|
84
|
+
};
|
|
69
85
|
this.#sizes.set(channel, this.size(channel) + 1);
|
|
70
86
|
this.#changed(channel);
|
|
71
87
|
const previous = this.#tails.get(channel) ?? Promise.resolve();
|
|
@@ -386,7 +386,7 @@ export class PiAgentRuntime implements AgentRuntime {
|
|
|
386
386
|
): Promise<string> {
|
|
387
387
|
const { dataDir } = this.#options;
|
|
388
388
|
const { signal } = task;
|
|
389
|
-
if (this.#options.stopping?.())
|
|
389
|
+
if (this.#options.stopping?.() || this.#options.draining?.())
|
|
390
390
|
throw new AgentRunError(new HostStoppingError().message);
|
|
391
391
|
// A task works at the tier of the turn that started it; without one there is no tier to take.
|
|
392
392
|
const turn = this.#turns.get(scope.turn);
|
|
@@ -137,6 +137,12 @@ export interface PiAgentRuntimeOptions {
|
|
|
137
137
|
turnAbortGraceMs?: number;
|
|
138
138
|
/** Whether the host is shutting down: a turn or a task is then refused before it starts. */
|
|
139
139
|
stopping?: () => boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Whether the host is shutting down, even inside the delivery of a report the drain waits for,
|
|
142
|
+
* where `stopping` reads false so that the report's own turn can run: a task that turn spawns
|
|
143
|
+
* is refused when this reads true. Default: never.
|
|
144
|
+
*/
|
|
145
|
+
draining?: () => boolean;
|
|
140
146
|
/**
|
|
141
147
|
* Whether a turn given a place for interim posts shows the text it writes before its final
|
|
142
148
|
* answer as it goes; default "on". "off" posts only the final reply.
|
|
@@ -4,13 +4,17 @@ import type {
|
|
|
4
4
|
AgentPost,
|
|
5
5
|
CategoryLayout,
|
|
6
6
|
ChannelMessage,
|
|
7
|
-
} from "
|
|
7
|
+
} from "../contract/agent-channels.ts";
|
|
8
8
|
|
|
9
9
|
/** The Discord channels of a team, recorded: what was posted, made, moved and read. */
|
|
10
10
|
export class FakeChannels implements AgentChannels {
|
|
11
11
|
posts: { channelId: string; post: AgentPost }[] = [];
|
|
12
12
|
created: string[] = [];
|
|
13
13
|
deleted = new Set<string>();
|
|
14
|
+
/** Channels that are another server's. */
|
|
15
|
+
foreign = new Set<string>();
|
|
16
|
+
/** Channels whose check fails with an error that says nothing of them. */
|
|
17
|
+
failing = new Set<string>();
|
|
14
18
|
#next = 2000;
|
|
15
19
|
async post(channelId: string, post: AgentPost) {
|
|
16
20
|
this.posts.push({ channelId, post });
|
|
@@ -14,6 +14,8 @@ export const PAGER = "pager";
|
|
|
14
14
|
interface Page {
|
|
15
15
|
name: string;
|
|
16
16
|
topic: string;
|
|
17
|
+
/** The page this one was made under, for a temp knight's thread. */
|
|
18
|
+
parent?: string;
|
|
17
19
|
archived: boolean;
|
|
18
20
|
messages: { id: number; author: string; text: string }[];
|
|
19
21
|
}
|
|
@@ -28,6 +30,12 @@ export class FakePager {
|
|
|
28
30
|
readonly #listeners: ((id: string) => void)[] = [];
|
|
29
31
|
#next = 1;
|
|
30
32
|
#message = 1;
|
|
33
|
+
readonly #prefix: string;
|
|
34
|
+
|
|
35
|
+
/** `prefix` starts the ids of the pages it makes (`pg-1`), so a test that binds ids of its own cannot meet them. */
|
|
36
|
+
constructor(prefix = "pg") {
|
|
37
|
+
this.#prefix = prefix;
|
|
38
|
+
}
|
|
31
39
|
|
|
32
40
|
readonly provider: PlaceProvider = {
|
|
33
41
|
surface: PAGER,
|
|
@@ -65,10 +73,11 @@ export class FakePager {
|
|
|
65
73
|
existing.archived = false;
|
|
66
74
|
return spec.existing;
|
|
67
75
|
}
|
|
68
|
-
const id =
|
|
76
|
+
const id = `${this.#prefix}-${this.#next++}`;
|
|
69
77
|
this.pages.set(id, {
|
|
70
78
|
name: spec.name,
|
|
71
79
|
topic: spec.topic,
|
|
80
|
+
...(spec.parent === undefined ? {} : { parent: spec.parent }),
|
|
72
81
|
archived: false,
|
|
73
82
|
messages: [],
|
|
74
83
|
});
|
|
@@ -77,7 +86,7 @@ export class FakePager {
|
|
|
77
86
|
remove: async (id) => {
|
|
78
87
|
const page = this.pages.get(id);
|
|
79
88
|
if (page) page.archived = true;
|
|
80
|
-
return
|
|
89
|
+
return `; its page ${id} is kept.`;
|
|
81
90
|
},
|
|
82
91
|
check: async (id): Promise<PlaceCheck> => {
|
|
83
92
|
if (id.startsWith("other-")) return "foreign";
|
|
@@ -93,6 +102,11 @@ export class FakePager {
|
|
|
93
102
|
mention: (key) => `page ${parseChannelKey(key).id}`,
|
|
94
103
|
};
|
|
95
104
|
|
|
105
|
+
/** The network already has a page `id` that the team did not make, as a bound place would be. */
|
|
106
|
+
adopt(id: string, name: string, topic = name): void {
|
|
107
|
+
this.pages.set(id, { name, topic, archived: false, messages: [] });
|
|
108
|
+
}
|
|
109
|
+
|
|
96
110
|
/** Everything a person reading the page of `key` has seen. */
|
|
97
111
|
seen(key: ChannelKey): readonly PlaceSeen[] {
|
|
98
112
|
return (this.pages.get(parseChannelKey(key).id)?.messages ?? []).map(
|
|
@@ -208,9 +208,10 @@ export async function setUpModules(
|
|
|
208
208
|
void record.posted.push({ channel, text: reply.chunks.join("") }),
|
|
209
209
|
},
|
|
210
210
|
]);
|
|
211
|
-
// SAFETY: setup and the preflight read only the logger, the conversations' background, targets and owners, the surfaces, the direct channels, and the services.
|
|
211
|
+
// SAFETY: setup and the preflight read only the logger, the conversations' background, targets and owners, the surfaces, the direct channels, and the services, and the queue's drain flags.
|
|
212
212
|
const context = {
|
|
213
213
|
logger: silentLogger(),
|
|
214
|
+
queue: { closed: false, draining: false },
|
|
214
215
|
conversations: {
|
|
215
216
|
target: (name: string) =>
|
|
216
217
|
options.ownerTarget !== false && name === PERSONAL_TARGET.name
|
|
@@ -325,8 +325,9 @@ const CHECKS: readonly Check[] = [
|
|
|
325
325
|
if (id === undefined) return;
|
|
326
326
|
const line = await provider.remove?.(id, { ...spec, helper: false });
|
|
327
327
|
expectThat(
|
|
328
|
-
line === undefined ||
|
|
329
|
-
|
|
328
|
+
line === undefined ||
|
|
329
|
+
(typeof line === "string" && /^[;,]\s/.test(line)),
|
|
330
|
+
'remove resolved to something that is no line of text starting with its own separator, `; ` or `, `, as `Archived "<name>"; its channel is kept.` reads',
|
|
330
331
|
);
|
|
331
332
|
if (provider.check)
|
|
332
333
|
expectThat(
|
|
@@ -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 DiscordTeamReads,
|
|
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,50 @@ 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: DiscordTeamReads,
|
|
104
|
+
): FormerChannelOps {
|
|
105
|
+
return discordChannelOps({
|
|
106
|
+
channels,
|
|
107
|
+
directory: () => directory,
|
|
62
108
|
logger: silentLogger(),
|
|
63
109
|
});
|
|
64
110
|
}
|
|
@@ -95,20 +141,40 @@ export function testPlacePort(options: {
|
|
|
95
141
|
};
|
|
96
142
|
}
|
|
97
143
|
|
|
98
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* The places of a team over fakes: Discord's provider when `discord` (over `channels`, which it
|
|
146
|
+
* posts through), a room on each of `rooms` (posting through `surfaces`), and `stored` rows.
|
|
147
|
+
*/
|
|
99
148
|
export function testPlaces(options: {
|
|
100
149
|
store: ConstructorParameters<typeof TeamPlaces>[0];
|
|
101
150
|
rows?: () => readonly StoredPlace[];
|
|
102
151
|
rooms?: () => readonly string[];
|
|
103
152
|
discord?: boolean;
|
|
153
|
+
/** The channels Discord's provider posts through; absent = it only reads places. */
|
|
154
|
+
channels?: Partial<AgentChannels>;
|
|
155
|
+
/** What the rooms' derived providers post through; absent = a post fails. */
|
|
156
|
+
surfaces?: Partial<SurfacePort>;
|
|
104
157
|
stored?: () => readonly PlaceProvider[];
|
|
105
158
|
}): TeamPlaces {
|
|
106
|
-
const discord =
|
|
159
|
+
const discord =
|
|
160
|
+
options.discord === false
|
|
161
|
+
? []
|
|
162
|
+
: [
|
|
163
|
+
discordTestPlaces(
|
|
164
|
+
TEST_AGENT_GUILD,
|
|
165
|
+
options.channels
|
|
166
|
+
? { channels: options.channels as AgentChannels }
|
|
167
|
+
: {},
|
|
168
|
+
),
|
|
169
|
+
];
|
|
107
170
|
return new TeamPlaces(
|
|
108
171
|
options.store,
|
|
109
172
|
storedFrom(options.rows ?? (() => [])),
|
|
110
173
|
testPlacePort({
|
|
111
174
|
...(options.rooms ? { rooms: options.rooms } : {}),
|
|
175
|
+
...(options.surfaces
|
|
176
|
+
? { surfaces: options.surfaces as SurfacePort }
|
|
177
|
+
: {}),
|
|
112
178
|
stored: () => [...discord, ...(options.stored?.() ?? [])],
|
|
113
179
|
}),
|
|
114
180
|
);
|
|
@@ -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,34 @@
|
|
|
1
1
|
// Supporting data types for the service and helper contracts.
|
|
2
2
|
|
|
3
3
|
export type {
|
|
4
|
-
AgentCategory,
|
|
5
|
-
AgentChannels,
|
|
6
4
|
AgentModels,
|
|
7
|
-
AgentPost,
|
|
8
5
|
AgentTurnRunner,
|
|
9
|
-
CategoryLayout,
|
|
10
|
-
ChannelMessage,
|
|
11
|
-
DashboardBoard,
|
|
12
6
|
} from "../core/agents/agent-ports.ts";
|
|
13
7
|
export type { Backlog, GroupMessage } from "../core/agents/agent-rules.ts";
|
|
14
|
-
|
|
8
|
+
|
|
9
|
+
// Deprecated here, removed from `pi-roundtable/kit` in 1.0: Discord's agent guild internals, which
|
|
10
|
+
// `pi-roundtable/discord` exports then (an entry holds a name once until 1.0). The aliases carry
|
|
11
|
+
// the tag, so the same types stay unmarked where `pi-roundtable/discord` hands them out.
|
|
12
|
+
import type * as AgentChannelTypes from "../core/contract/agent-channels.ts";
|
|
13
|
+
|
|
14
|
+
/** @deprecated Since 0.46 a Discord internal: its export from `pi-roundtable/kit` goes away in 1.0, and `pi-roundtable/discord` exports it then. */
|
|
15
|
+
export type AgentCategory = AgentChannelTypes.AgentCategory;
|
|
16
|
+
|
|
17
|
+
/** @deprecated Since 0.46 a Discord internal: its export from `pi-roundtable/kit` goes away in 1.0, and `pi-roundtable/discord` exports it then. */
|
|
18
|
+
export type AgentChannels = AgentChannelTypes.AgentChannels;
|
|
19
|
+
|
|
20
|
+
/** @deprecated Since 0.46 a Discord internal: its export from `pi-roundtable/kit` goes away in 1.0, and `pi-roundtable/discord` exports it then. */
|
|
21
|
+
export type AgentPost = AgentChannelTypes.AgentPost;
|
|
22
|
+
|
|
23
|
+
/** @deprecated Since 0.46 a Discord internal: its export from `pi-roundtable/kit` goes away in 1.0, and `pi-roundtable/discord` exports it then. */
|
|
24
|
+
export type CategoryLayout = AgentChannelTypes.CategoryLayout;
|
|
25
|
+
|
|
26
|
+
/** @deprecated Since 0.46 a Discord internal: its export from `pi-roundtable/kit` goes away in 1.0, and `pi-roundtable/discord` exports it then. */
|
|
27
|
+
export type ChannelMessage = AgentChannelTypes.ChannelMessage;
|
|
28
|
+
|
|
29
|
+
/** @deprecated Since 0.46 a Discord internal: its export from `pi-roundtable/kit` goes away in 1.0, and `pi-roundtable/discord` exports it then. */
|
|
30
|
+
export type DashboardBoard = AgentChannelTypes.DashboardBoard;
|
|
31
|
+
|
|
15
32
|
export type {
|
|
16
33
|
EffortPolicy,
|
|
17
34
|
EffortRequest,
|
|
@@ -22,5 +39,6 @@ export type { Notifier, OwnerNotifier } from "../core/domain/ports.ts";
|
|
|
22
39
|
export type { SpeakerFacts, SpeakerPolicy } from "../core/identity/speakers.ts";
|
|
23
40
|
export type { DelegationWorker } from "../core/modules/delegation/delegator.ts";
|
|
24
41
|
export type { AgentChannelLookup } from "../core/modules/schedules/schedules.ts";
|
|
42
|
+
export type { AgentOps } from "../core/plugin-api/agent-ops.ts";
|
|
25
43
|
export type { AssistantLike } from "../core/shared/session-messages.ts";
|
|
26
44
|
export type { ThreadHost } from "../core/threads/dispatch-threads.ts";
|