feat: add OpenClaw plugin skeleton / 新增 OpenClaw plugin skeleton

This commit is contained in:
Alice (OpenClaw)
2026-05-14 09:27:41 +08:00
parent 3981364d9b
commit 62bbe3bd18
2 changed files with 73 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import test from "node:test"
import assert from "node:assert/strict"
import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import { buildOpenClawReplyEndPresentation, createOpenClawReplyEndInteractiveRegistration } from "../src/adapters/openclaw-plugin-skeleton.ts"
test("plugin skeleton builds OpenClaw message-tool presentation", () => {
const payload = buildOpenClawReplyEndPresentation("864811879", "hello")
assert.equal(payload.channel, "telegram")
assert.equal(payload.target, "864811879")
assert.equal(payload.presentation.blocks[1].type, "buttons")
})
test("plugin skeleton interactive registration handles continue callback", async () => {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "reply-end-plugin-skel-"))
const calls = []
const registration = createOpenClawReplyEndInteractiveRegistration(tempDir)
assert.equal(registration.namespace, "rec")
const handled = await registration.handler({
callback: {
data: "rec:continue",
messageId: "99",
chatId: "864811879",
},
conversationId: "864811879",
sessionKey: "agent:main:main",
callbackId: "cb-99",
respond: {
editButtons: async (input) => calls.push(["editButtons", input]),
reply: async (input) => calls.push(["reply", input]),
},
})
assert.equal(handled, true)
assert.equal(calls[0][0], "editButtons")
assert.equal(calls[1][0], "reply")
})