mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-28 08:52:45 +00:00
Docs: point message runtime docs and tests at plugin-owned code
This commit is contained in:
13
docs/pi.md
13
docs/pi.md
@@ -119,19 +119,24 @@ src/agents/
|
|||||||
│ ├── browser-tool.ts
|
│ ├── browser-tool.ts
|
||||||
│ ├── canvas-tool.ts
|
│ ├── canvas-tool.ts
|
||||||
│ ├── cron-tool.ts
|
│ ├── cron-tool.ts
|
||||||
│ ├── discord-actions*.ts
|
|
||||||
│ ├── gateway-tool.ts
|
│ ├── gateway-tool.ts
|
||||||
│ ├── image-tool.ts
|
│ ├── image-tool.ts
|
||||||
│ ├── message-tool.ts
|
│ ├── message-tool.ts
|
||||||
│ ├── nodes-tool.ts
|
│ ├── nodes-tool.ts
|
||||||
│ ├── session*.ts
|
│ ├── session*.ts
|
||||||
│ ├── slack-actions.ts
|
|
||||||
│ ├── telegram-actions.ts
|
|
||||||
│ ├── web-*.ts
|
│ ├── web-*.ts
|
||||||
│ └── whatsapp-actions.ts
|
│ └── ...
|
||||||
└── ...
|
└── ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Channel-specific message action runtimes now live in the plugin-owned extension
|
||||||
|
directories instead of under `src/agents/tools`, for example:
|
||||||
|
|
||||||
|
- `extensions/discord/src/actions/runtime*.ts`
|
||||||
|
- `extensions/slack/src/action-runtime.ts`
|
||||||
|
- `extensions/telegram/src/action-runtime.ts`
|
||||||
|
- `extensions/whatsapp/src/action-runtime.ts`
|
||||||
|
|
||||||
## Core Integration Flow
|
## Core Integration Flow
|
||||||
|
|
||||||
### 1. Running an Embedded Agent
|
### 1. Running an Embedded Agent
|
||||||
|
|||||||
@@ -228,6 +228,13 @@ responsible for forwarding the current chat/session identity into the plugin
|
|||||||
discovery boundary so the shared `message` tool exposes the right channel-owned
|
discovery boundary so the shared `message` tool exposes the right channel-owned
|
||||||
surface for the current turn.
|
surface for the current turn.
|
||||||
|
|
||||||
|
For channel-owned execution helpers, bundled plugins should keep the execution
|
||||||
|
runtime inside their own extension modules. Core no longer owns the Discord,
|
||||||
|
Slack, Telegram, or WhatsApp message-action runtimes under `src/agents/tools`.
|
||||||
|
`agent-runtime` still re-exports the Discord and Telegram helpers for backward
|
||||||
|
compatibility, but we do not publish separate `plugin-sdk/*-action-runtime`
|
||||||
|
subpaths and new plugins should import their own local runtime code directly.
|
||||||
|
|
||||||
## Capability ownership model
|
## Capability ownership model
|
||||||
|
|
||||||
OpenClaw treats a native plugin as the ownership boundary for a **company** or a
|
OpenClaw treats a native plugin as the ownership boundary for a **company** or a
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ const sendReactionSignal = vi.fn(async (..._args: unknown[]) => ({ ok: true }));
|
|||||||
const removeReactionSignal = vi.fn(async (..._args: unknown[]) => ({ ok: true }));
|
const removeReactionSignal = vi.fn(async (..._args: unknown[]) => ({ ok: true }));
|
||||||
const handleSlackAction = vi.fn(async (..._args: unknown[]) => ({ details: { ok: true } }));
|
const handleSlackAction = vi.fn(async (..._args: unknown[]) => ({ details: { ok: true } }));
|
||||||
|
|
||||||
vi.mock("../../../agents/tools/discord-actions.js", () => ({
|
vi.mock("../../../../extensions/discord/src/actions/runtime.js", () => ({
|
||||||
handleDiscordAction,
|
handleDiscordAction,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("../../../agents/tools/telegram-actions.js", () => ({
|
vi.mock("../../../../extensions/telegram/src/action-runtime.js", () => ({
|
||||||
handleTelegramAction,
|
handleTelegramAction,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ vi.mock("../../../../extensions/signal/src/send-reactions.js", () => ({
|
|||||||
removeReactionSignal,
|
removeReactionSignal,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("../../../agents/tools/slack-actions.js", () => ({
|
vi.mock("../../../../extensions/slack/runtime-api.js", () => ({
|
||||||
handleSlackAction,
|
handleSlackAction,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -18,43 +18,54 @@ vi.mock("../config/config.js", async (importOriginal) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const resolveCommandSecretRefsViaGateway = vi.fn(async ({ config }: { config: unknown }) => ({
|
const { resolveCommandSecretRefsViaGateway, callGatewayMock } = vi.hoisted(() => ({
|
||||||
resolvedConfig: config,
|
resolveCommandSecretRefsViaGateway: vi.fn(async ({ config }: { config: unknown }) => ({
|
||||||
diagnostics: [] as string[],
|
resolvedConfig: config,
|
||||||
|
diagnostics: [] as string[],
|
||||||
|
})),
|
||||||
|
callGatewayMock: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
vi.mock("../cli/command-secret-gateway.js", () => ({
|
vi.mock("../cli/command-secret-gateway.js", () => ({
|
||||||
resolveCommandSecretRefsViaGateway,
|
resolveCommandSecretRefsViaGateway,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const callGatewayMock = vi.fn();
|
|
||||||
vi.mock("../gateway/call.js", () => ({
|
vi.mock("../gateway/call.js", () => ({
|
||||||
callGateway: callGatewayMock,
|
callGateway: callGatewayMock,
|
||||||
callGatewayLeastPrivilege: callGatewayMock,
|
callGatewayLeastPrivilege: callGatewayMock,
|
||||||
randomIdempotencyKey: () => "idem-1",
|
randomIdempotencyKey: () => "idem-1",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const webAuthExists = vi.fn(async () => false);
|
const webAuthExists = vi.hoisted(() => vi.fn(async () => false));
|
||||||
vi.mock("../../extensions/whatsapp/src/session.js", () => ({
|
vi.mock("../../extensions/whatsapp/src/session.js", () => ({
|
||||||
webAuthExists,
|
webAuthExists,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const handleDiscordAction = vi.fn(async (..._args: unknown[]) => ({ details: { ok: true } }));
|
const handleDiscordAction = vi.hoisted(() =>
|
||||||
vi.mock("../agents/tools/discord-actions.js", () => ({
|
vi.fn(async (..._args: unknown[]) => ({ details: { ok: true } })),
|
||||||
|
);
|
||||||
|
vi.mock("../../extensions/discord/src/actions/runtime.js", () => ({
|
||||||
handleDiscordAction,
|
handleDiscordAction,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const handleSlackAction = vi.fn(async (..._args: unknown[]) => ({ details: { ok: true } }));
|
const handleSlackAction = vi.hoisted(() =>
|
||||||
vi.mock("../agents/tools/slack-actions.js", () => ({
|
vi.fn(async (..._args: unknown[]) => ({ details: { ok: true } })),
|
||||||
|
);
|
||||||
|
vi.mock("../../extensions/slack/runtime-api.js", () => ({
|
||||||
handleSlackAction,
|
handleSlackAction,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const handleTelegramAction = vi.fn(async (..._args: unknown[]) => ({ details: { ok: true } }));
|
const handleTelegramAction = vi.hoisted(() =>
|
||||||
vi.mock("../agents/tools/telegram-actions.js", () => ({
|
vi.fn(async (..._args: unknown[]) => ({ details: { ok: true } })),
|
||||||
|
);
|
||||||
|
vi.mock("../../extensions/telegram/src/action-runtime.js", () => ({
|
||||||
handleTelegramAction,
|
handleTelegramAction,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const handleWhatsAppAction = vi.fn(async (..._args: unknown[]) => ({ details: { ok: true } }));
|
const handleWhatsAppAction = vi.hoisted(() =>
|
||||||
vi.mock("../agents/tools/whatsapp-actions.js", () => ({
|
vi.fn(async (..._args: unknown[]) => ({ details: { ok: true } })),
|
||||||
|
);
|
||||||
|
vi.mock("../../extensions/whatsapp/runtime-api.js", () => ({
|
||||||
handleWhatsAppAction,
|
handleWhatsAppAction,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -66,10 +77,12 @@ const setRegistry = async (registry: ReturnType<typeof createTestRegistry>) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
vi.resetModules();
|
||||||
envSnapshot = captureEnv(["TELEGRAM_BOT_TOKEN", "DISCORD_BOT_TOKEN"]);
|
envSnapshot = captureEnv(["TELEGRAM_BOT_TOKEN", "DISCORD_BOT_TOKEN"]);
|
||||||
process.env.TELEGRAM_BOT_TOKEN = "";
|
process.env.TELEGRAM_BOT_TOKEN = "";
|
||||||
process.env.DISCORD_BOT_TOKEN = "";
|
process.env.DISCORD_BOT_TOKEN = "";
|
||||||
testConfig = {};
|
testConfig = {};
|
||||||
|
({ messageCommand } = await import("./message.js"));
|
||||||
await setRegistry(createTestRegistry([]));
|
await setRegistry(createTestRegistry([]));
|
||||||
callGatewayMock.mockClear();
|
callGatewayMock.mockClear();
|
||||||
webAuthExists.mockClear().mockResolvedValue(false);
|
webAuthExists.mockClear().mockResolvedValue(false);
|
||||||
@@ -184,7 +197,7 @@ const createTelegramPollPluginRegistration = () => ({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { messageCommand } = await import("./message.js");
|
let messageCommand: typeof import("./message.js").messageCommand;
|
||||||
|
|
||||||
function createTelegramSecretRawConfig() {
|
function createTelegramSecretRawConfig() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ function listExtensionFiles(): {
|
|||||||
|
|
||||||
function listHighRiskRuntimeCfgFiles(): string[] {
|
function listHighRiskRuntimeCfgFiles(): string[] {
|
||||||
return [
|
return [
|
||||||
"src/agents/tools/telegram-actions.ts",
|
"extensions/telegram/src/action-runtime.ts",
|
||||||
"extensions/discord/src/monitor/reply-delivery.ts",
|
"extensions/discord/src/monitor/reply-delivery.ts",
|
||||||
"extensions/discord/src/monitor/thread-bindings.discord-api.ts",
|
"extensions/discord/src/monitor/thread-bindings.discord-api.ts",
|
||||||
"extensions/discord/src/monitor/thread-bindings.manager.ts",
|
"extensions/discord/src/monitor/thread-bindings.manager.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user