pi-roundtable 0.1.0 → 0.2.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 +138 -0
- package/README.md +6 -4
- package/docs/plugins.md +1448 -66
- package/examples/echo-runtime.test.ts +122 -0
- package/examples/echo-runtime.ts +107 -0
- package/examples/events.test.ts +1 -0
- package/examples/events.ts +2 -2
- package/examples/fake-surface.test.ts +180 -0
- package/examples/fake-surface.ts +109 -0
- package/examples/interactions.test.ts +12 -3
- package/examples/interactions.ts +19 -19
- package/examples/shared-services.test.ts +74 -0
- package/examples/shared-services.ts +60 -0
- package/examples/study-room.test.ts +69 -0
- package/examples/study-room.ts +52 -0
- package/examples/support-desk.test.ts +34 -0
- package/examples/support-desk.ts +40 -0
- package/package.json +9 -2
- package/src/cli/checks/database.ts +11 -30
- package/src/cli/checks/images.ts +19 -0
- package/src/cli/doctor.ts +6 -0
- package/src/cli/main.ts +2 -1
- package/src/core/agents/agent-claim.ts +42 -16
- package/src/core/agents/agent-messages.ts +4 -4
- package/src/core/agents/agent-ports.ts +8 -21
- package/src/core/agents/agent-prompt.ts +3 -1
- package/src/core/agents/agent-store.ts +6 -4
- package/src/core/agents/agent-team-fixture.ts +389 -0
- package/src/core/agents/agent-team.ts +26 -25
- package/src/core/agents/agent-tools.ts +34 -15
- package/src/core/agents/avatar-studio.ts +40 -6
- package/src/core/agents/fallback-avatar.ts +85 -0
- package/src/core/agents/team-editing.ts +49 -10
- package/src/core/agents/team-keys.ts +22 -9
- package/src/core/agents/team-layout.ts +4 -3
- package/src/core/agents/team-lifecycle.ts +28 -2
- package/src/core/agents/team-options.ts +9 -5
- package/src/core/agents/team-status.ts +4 -4
- package/src/core/agents/team-text.ts +8 -6
- package/src/core/agents/team-turn-types.ts +4 -4
- package/src/core/agents/team-turns.ts +6 -5
- package/src/core/builtin/agent-server.ts +187 -121
- package/src/core/builtin/discord-admin.ts +41 -0
- package/src/core/builtin/discord.ts +65 -40
- package/src/core/builtin/modules.ts +67 -58
- package/src/core/builtin/session-tool.ts +24 -0
- package/src/core/builtin/skills.ts +72 -0
- package/src/core/builtin/stores.ts +55 -31
- package/src/core/config/config.ts +45 -4
- package/src/core/config/schema.ts +6 -0
- package/src/core/contract/channels.ts +54 -14
- package/src/core/contract/providers.ts +17 -0
- package/src/core/contract/runtime.ts +138 -0
- package/src/core/contract/services.ts +45 -0
- package/src/core/contract/surface.ts +88 -0
- package/src/core/db/migrations.ts +118 -3
- package/src/core/define-roundtable.ts +70 -46
- package/src/core/define.ts +2 -1
- package/src/core/discord/agent-commands.ts +39 -14
- package/src/core/discord/agent-panel.ts +66 -0
- package/src/core/discord/channel-executor.ts +6 -3
- package/src/core/discord/channel-operations.ts +14 -11
- package/src/core/discord/command-collection.ts +46 -0
- package/src/core/{registry/interactions.ts → discord/compose-commands.ts} +5 -5
- package/src/core/discord/connection.ts +35 -0
- package/src/core/discord/discord-surface.ts +32 -94
- package/src/core/discord/dispatch-threads.ts +2 -2
- package/src/core/discord/inbound-message.ts +99 -0
- package/src/core/discord/interaction-module.ts +57 -1
- package/src/core/discord/owner-cards.ts +4 -4
- package/src/core/discord/owner-command.ts +44 -11
- package/src/core/discord/owner-discord.ts +2 -2
- package/src/core/discord/schedule-commands.ts +21 -18
- package/src/core/discord/stop-button.ts +44 -1
- package/src/core/domain/attachment.ts +12 -8
- package/src/core/domain/conversation.ts +3 -4
- package/src/core/domain/owner-prompts.ts +5 -5
- package/src/core/domain/ports.ts +9 -53
- package/src/core/freeze.ts +9 -0
- package/src/core/host.ts +255 -82
- package/src/core/http/listeners.ts +55 -20
- package/src/core/i18n/agent-panel.ts +4 -0
- package/src/core/i18n/index.ts +12 -2
- package/src/core/i18n/owner.ts +7 -1
- package/src/core/i18n/schedules.ts +12 -6
- package/src/core/identity.ts +1 -1
- package/src/core/judging/effort-judge.ts +25 -3
- package/src/core/log.ts +21 -3
- package/src/core/models.ts +2 -2
- package/src/core/modules/background/background-turns.ts +6 -4
- package/src/core/modules/delegation/delegate.ts +3 -2
- package/src/core/modules/delegation/delegator.ts +15 -13
- package/src/core/modules/delegation/{sol-worker.ts → web-research-worker.ts} +6 -6
- package/src/core/modules/discord-admin/discord-admin.ts +6 -6
- package/src/core/modules/host-shell/shell-policy.ts +8 -3
- package/src/core/modules/memory/owner-memory-store.ts +27 -25
- package/src/core/modules/memory/owner-memory.ts +9 -13
- package/src/core/modules/schedules/recurrence.ts +5 -3
- package/src/core/modules/schedules/schedule-store.ts +11 -11
- package/src/core/modules/schedules/schedule-tools.ts +22 -20
- package/src/core/modules/schedules/scheduler.ts +7 -2
- package/src/core/modules/schedules/schedules.ts +9 -3
- package/src/core/modules/skills/skill-registry.ts +3 -2
- package/src/core/modules/skills/skill-store.ts +2 -15
- package/src/core/modules/skills/skill-tools.ts +10 -4
- package/src/core/ops/error-reporter.ts +1 -1
- package/src/core/plugin.ts +232 -28
- package/src/core/registry/contributions.ts +173 -14
- package/src/core/registry/providers.ts +35 -5
- package/src/core/registry/services.ts +229 -0
- package/src/core/routing/channel-queue.ts +5 -0
- package/src/core/routing/channel-router.ts +21 -7
- package/src/core/routing/conversation-turns.ts +139 -0
- package/src/core/routing/message-text.ts +9 -2
- package/src/core/routing/surface-port.ts +39 -0
- package/src/core/runtime/conversation-sessions.ts +4 -3
- package/src/core/runtime/extensions/confirmation-fixture.ts +11 -0
- package/src/core/runtime/extensions/confirmation-gate.ts +11 -9
- package/src/core/runtime/mcp.ts +1 -1
- package/src/core/runtime/pending-confirmation-store.ts +10 -12
- package/src/core/runtime/pi-agent-runtime.ts +9 -6
- package/src/core/runtime/prompt-slot.ts +8 -3
- package/src/core/runtime/runtime-types.ts +9 -35
- package/src/core/runtime/session-factory.ts +21 -5
- package/src/core/runtime/text-tools.ts +1 -3
- package/src/core/services.ts +238 -90
- package/src/core/sessions.ts +3 -2
- package/src/core/shared/{profile-tools.ts → active-tools.ts} +2 -2
- package/src/core/shared/delegate-tool.ts +4 -3
- package/src/core/shared/schedule-tools.ts +22 -13
- package/src/core/shared/session-messages.ts +1 -1
- package/src/core/speakers.ts +6 -38
- package/src/core/testing/database.ts +1 -7
- package/src/core/testing/eager-catalog.ts +30 -0
- package/src/core/testing/locale.ts +23 -5
- package/src/core/testing/modules.ts +105 -41
- package/src/core/testing/test-host.ts +279 -0
- package/src/core/testing/tool-set.ts +64 -0
- package/src/core/time.ts +6 -1
- package/src/core/tool-set.snapshot.json +288 -0
- package/src/core/tool-tiers.ts +17 -57
- package/src/discord/index.ts +64 -0
- package/src/index.ts +181 -10
- package/src/kit/channels.ts +14 -0
- package/src/kit/domain.ts +18 -0
- package/src/kit/holds.ts +4 -0
- package/src/kit/index.ts +129 -0
- package/src/kit/judging.ts +10 -0
- package/src/kit/memory.ts +3 -0
- package/src/kit/mirror.ts +19 -0
- package/src/kit/presentation.ts +7 -0
- package/src/kit/shell.ts +7 -0
- package/src/kit/skills.ts +8 -0
- package/src/kit/support.ts +21 -0
- package/src/kit/threads.ts +7 -0
- package/src/kit/tools.ts +14 -0
- package/src/kit/worker.ts +16 -0
- package/src/testing.ts +394 -34
- package/examples/guide.test.ts +0 -52
- package/src/cli/add-plugin.test.ts +0 -107
- package/src/cli/checks/basic.test.ts +0 -276
- package/src/cli/checks/database.test.ts +0 -117
- package/src/cli/checks/discord.test.ts +0 -200
- package/src/cli/cli.test.ts +0 -122
- package/src/cli/config-edit.test.ts +0 -130
- package/src/cli/doctor.test.ts +0 -184
- package/src/cli/init.test.ts +0 -127
- package/src/cli/size.test.ts +0 -9
- package/src/cli/templates.test.ts +0 -129
- package/src/cli/testing/fixtures.ts +0 -106
- package/src/core/agents/agent-claim.test.ts +0 -142
- package/src/core/agents/agent-dashboard.test.ts +0 -120
- package/src/core/agents/agent-guild.test.ts +0 -124
- package/src/core/agents/agent-store.test.ts +0 -205
- package/src/core/agents/avatar-studio.test.ts +0 -88
- package/src/core/agents/group-round.test.ts +0 -143
- package/src/core/agents/owner-identity.test.ts +0 -172
- package/src/core/agents/team-turns.test.ts +0 -278
- package/src/core/attachments/attachments.test.ts +0 -85
- package/src/core/boundary.test.ts +0 -45
- package/src/core/builtin/modules.test.ts +0 -127
- package/src/core/config/config.test.ts +0 -135
- package/src/core/contract/discord.ts +0 -33
- package/src/core/db/migrations.test.ts +0 -237
- package/src/core/define-roundtable.test.ts +0 -134
- package/src/core/define.test.ts +0 -144
- package/src/core/discord/agent-commands.test.ts +0 -58
- package/src/core/discord/agent-discord.test.ts +0 -70
- package/src/core/discord/dispatch-thread-host.test.ts +0 -114
- package/src/core/discord/dispatch-threads.test.ts +0 -94
- package/src/core/discord/owner-cards.test.ts +0 -435
- package/src/core/discord/owner-discord.test.ts +0 -325
- package/src/core/domain/expression.ts +0 -21
- package/src/core/domain/profile.ts +0 -32
- package/src/core/drain.test.ts +0 -46
- package/src/core/events.test.ts +0 -81
- package/src/core/holds.test.ts +0 -54
- package/src/core/host.test.ts +0 -536
- package/src/core/http/listeners.test.ts +0 -164
- package/src/core/i18n/i18n.test.ts +0 -139
- package/src/core/identity.test.ts +0 -18
- package/src/core/judging/effort-judge.test.ts +0 -112
- package/src/core/judging/model-judge.test.ts +0 -126
- package/src/core/modules/delegation/delegator.test.ts +0 -170
- package/src/core/modules/memory/owner-memory-store.test.ts +0 -244
- package/src/core/modules/schedules/schedule.test.ts +0 -358
- package/src/core/modules/skills/skill-kind.test.ts +0 -55
- package/src/core/modules/skills/skill-registry.test.ts +0 -376
- package/src/core/ops/error-reporter.test.ts +0 -283
- package/src/core/presentation/card-cadence.ts +0 -41
- package/src/core/presentation/presentation.test.ts +0 -166
- package/src/core/public-entry.test.ts +0 -59
- package/src/core/registry/contributions.test.ts +0 -215
- package/src/core/registry/interactions.test.ts +0 -87
- package/src/core/registry/providers.test.ts +0 -103
- package/src/core/routing/channel-queue.test.ts +0 -31
- package/src/core/routing/channel-router.test.ts +0 -326
- package/src/core/routing/conversation-kind.ts +0 -14
- package/src/core/routing/settle-turn.test.ts +0 -21
- package/src/core/runtime/compaction-tiers.test.ts +0 -227
- package/src/core/runtime/extensions/ask-user.test.ts +0 -114
- package/src/core/runtime/extensions/self-compact-guard.test.ts +0 -50
- package/src/core/runtime/pending-confirmation-store.test.ts +0 -52
- package/src/core/runtime/session-archive.test.ts +0 -20
- package/src/core/runtime/steerable-run.test.ts +0 -264
- package/src/core/runtime/text-tools.test.ts +0 -110
- package/src/core/runtime/turn-answer.test.ts +0 -72
- package/src/core/runtime/worker-task.test.ts +0 -82
- package/src/core/services.test.ts +0 -28
- package/src/core/sessions.test.ts +0 -85
- package/src/core/shared/unix-server.ts +0 -18
- package/src/core/size.test.ts +0 -9
- package/src/core/speakers.test.ts +0 -78
- package/src/core/testing/file-size.ts +0 -34
- package/src/core/time.test.ts +0 -166
- package/src/core/tool-tiers.test.ts +0 -117
- package/src/entries.test.ts +0 -112
- package/src/testing.test.ts +0 -156
package/src/testing.test.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { Type } from "typebox";
|
|
3
|
-
import { definePlugin, defineTool, ToolRefusal } from "./index.ts";
|
|
4
|
-
import { testPlugin } from "./testing.ts";
|
|
5
|
-
|
|
6
|
-
const note = defineTool({
|
|
7
|
-
name: "note_add",
|
|
8
|
-
description: "Write a note",
|
|
9
|
-
parameters: Type.Object({ text: Type.String() }),
|
|
10
|
-
minTier: "member",
|
|
11
|
-
hold: (args) => (args.text === "danger" ? "Confirm note" : undefined),
|
|
12
|
-
run: (args, turn) => {
|
|
13
|
-
if (!args.text) throw new ToolRefusal("empty note");
|
|
14
|
-
return `${turn.speaker?.name ?? "anonymous"}: ${args.text}`;
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("the harness registers tools through their session factories and records tiers and holds", async () => {
|
|
19
|
-
const harness = await testPlugin(
|
|
20
|
-
definePlugin({ name: "notes", setup: () => ({ tools: [note] }) }),
|
|
21
|
-
);
|
|
22
|
-
expect(harness.tools).toEqual(["note_add"]);
|
|
23
|
-
expect(harness.tiers.minTier("note_add")).toBe("member");
|
|
24
|
-
expect(
|
|
25
|
-
harness.contribution.holdRules?.[0]?.describe(
|
|
26
|
-
"note_add",
|
|
27
|
-
{ text: "danger" },
|
|
28
|
-
{},
|
|
29
|
-
),
|
|
30
|
-
).toBe("Confirm note");
|
|
31
|
-
expect(
|
|
32
|
-
await harness.runTool(
|
|
33
|
-
"note_add",
|
|
34
|
-
{ text: "hello" },
|
|
35
|
-
{ speaker: { id: "1", name: "Alice", tier: "owner" } },
|
|
36
|
-
),
|
|
37
|
-
).toBe("Alice: hello");
|
|
38
|
-
expect(await harness.runTool("note_add", { text: "" })).toBe("empty note");
|
|
39
|
-
await harness.stop();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test("ordinary tool errors reject the call rather than becoming model-visible refusals", async () => {
|
|
43
|
-
const broken = defineTool({
|
|
44
|
-
name: "broken_tool",
|
|
45
|
-
description: "Fail",
|
|
46
|
-
parameters: Type.Object({}),
|
|
47
|
-
minTier: "owner",
|
|
48
|
-
run: () => {
|
|
49
|
-
throw new Error("disk unavailable");
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
const harness = await testPlugin(
|
|
53
|
-
definePlugin({ name: "broken", setup: () => ({ tools: [broken] }) }),
|
|
54
|
-
);
|
|
55
|
-
await expect(harness.runTool("broken_tool", {})).rejects.toThrow(
|
|
56
|
-
"disk unavailable",
|
|
57
|
-
);
|
|
58
|
-
await harness.stop();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("database and built-in services fail with the host's errors until provided", async () => {
|
|
62
|
-
let databaseError = "";
|
|
63
|
-
let coreError = "";
|
|
64
|
-
const harness = await testPlugin(
|
|
65
|
-
definePlugin({
|
|
66
|
-
name: "ports",
|
|
67
|
-
setup: (context) => {
|
|
68
|
-
try {
|
|
69
|
-
context.database();
|
|
70
|
-
} catch (error) {
|
|
71
|
-
databaseError = String(error);
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
context.core.stores;
|
|
75
|
-
} catch (error) {
|
|
76
|
-
coreError = String(error);
|
|
77
|
-
}
|
|
78
|
-
return { events: {} };
|
|
79
|
-
},
|
|
80
|
-
}),
|
|
81
|
-
);
|
|
82
|
-
expect(databaseError).toBe("PluginError: no database is configured");
|
|
83
|
-
expect(coreError).toContain("core service stores is not provided yet");
|
|
84
|
-
await harness.stop();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test("events reach the plugin and are recorded", async () => {
|
|
88
|
-
const received: string[] = [];
|
|
89
|
-
const harness = await testPlugin(
|
|
90
|
-
definePlugin({
|
|
91
|
-
name: "listener",
|
|
92
|
-
setup: (context) => {
|
|
93
|
-
context.events.turnStarted({
|
|
94
|
-
agent: "helper",
|
|
95
|
-
channel: "test:1",
|
|
96
|
-
speaker: undefined,
|
|
97
|
-
});
|
|
98
|
-
return {
|
|
99
|
-
events: {
|
|
100
|
-
shutdown: () => {
|
|
101
|
-
received.push("shutdown");
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
|
-
}),
|
|
107
|
-
);
|
|
108
|
-
expect(harness.events).toEqual([
|
|
109
|
-
{
|
|
110
|
-
name: "turnStarted",
|
|
111
|
-
turn: { agent: "helper", channel: "test:1", speaker: undefined },
|
|
112
|
-
},
|
|
113
|
-
]);
|
|
114
|
-
await harness.stop();
|
|
115
|
-
expect(received).toEqual(["shutdown"]);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
test("a plugin that adds nothing gets the host's exact refusal", async () => {
|
|
119
|
-
await expect(
|
|
120
|
-
testPlugin(definePlugin({ name: "empty", setup: () => ({}) })),
|
|
121
|
-
).rejects.toThrow(
|
|
122
|
-
"plugin empty adds nothing. Give it a part (tools, services, channels, and so on), a migration, or a provider, or remove it.",
|
|
123
|
-
);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test("sessions read during setup carry the host's NotLinkedError text", async () => {
|
|
127
|
-
await expect(
|
|
128
|
-
testPlugin(
|
|
129
|
-
definePlugin({
|
|
130
|
-
name: "early",
|
|
131
|
-
setup: (context) => {
|
|
132
|
-
context.sessions();
|
|
133
|
-
return { events: {} };
|
|
134
|
-
},
|
|
135
|
-
}),
|
|
136
|
-
),
|
|
137
|
-
).rejects.toThrow(
|
|
138
|
-
"session parts are linked once every plugin is set up. Call sessions() from a service's start or from a handler, not during setup.",
|
|
139
|
-
);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
test("the harness returns the agent selection a plugin contributes", async () => {
|
|
143
|
-
const harness = await testPlugin(
|
|
144
|
-
definePlugin({
|
|
145
|
-
name: "selecting",
|
|
146
|
-
setup: () => ({
|
|
147
|
-
agentSelection: () => ({ tools: ["note_add"], groups: [] }),
|
|
148
|
-
}),
|
|
149
|
-
}),
|
|
150
|
-
);
|
|
151
|
-
expect(harness.contribution.agentSelection?.()).toEqual({
|
|
152
|
-
tools: ["note_add"],
|
|
153
|
-
groups: [],
|
|
154
|
-
});
|
|
155
|
-
await harness.stop();
|
|
156
|
-
});
|