























@@ -1620,6 +1620,85 @@ describe("loadOpenClawPlugins", () => {
16201620]);
16211621},
16221622},
1623+{
1624+label: "adapts returned plugin gateway method values into responses",
1625+run: async () => {
1626+useNoBundledPlugins();
1627+const plugin = writePlugin({
1628+id: "returned-gateway-method",
1629+filename: "returned-gateway-method.cjs",
1630+body: `module.exports = {
1631+ id: "returned-gateway-method",
1632+ register(api) {
1633+ api.registerGatewayMethod("returned-gateway-method.status", async () => ({ ok: true, status: "ready" }));
1634+ },
1635+};`,
1636+});
1637+1638+const registry = loadOpenClawPlugins({
1639+cache: false,
1640+workspaceDir: plugin.dir,
1641+config: {
1642+plugins: {
1643+load: { paths: [plugin.file] },
1644+allow: ["returned-gateway-method"],
1645+},
1646+},
1647+});
1648+1649+const responses: unknown[] = [];
1650+await registry.gatewayHandlers["returned-gateway-method.status"]?.({
1651+params: {},
1652+respond: (ok: boolean, payload: unknown, error?: unknown) =>
1653+responses.push({ ok, payload, error }),
1654+} as never);
1655+1656+expect(responses).toEqual([
1657+{ ok: true, payload: { ok: true, status: "ready" }, error: undefined },
1658+]);
1659+},
1660+},
1661+{
1662+label: "keeps explicit plugin gateway responses authoritative",
1663+run: async () => {
1664+useNoBundledPlugins();
1665+const plugin = writePlugin({
1666+id: "explicit-gateway-method",
1667+filename: "explicit-gateway-method.cjs",
1668+body: `module.exports = {
1669+ id: "explicit-gateway-method",
1670+ register(api) {
1671+ api.registerGatewayMethod("explicit-gateway-method.status", ({ respond }) => {
1672+ respond(true, { status: "responded" });
1673+ return { status: "returned" };
1674+ });
1675+ },
1676+};`,
1677+});
1678+1679+const registry = loadOpenClawPlugins({
1680+cache: false,
1681+workspaceDir: plugin.dir,
1682+config: {
1683+plugins: {
1684+load: { paths: [plugin.file] },
1685+allow: ["explicit-gateway-method"],
1686+},
1687+},
1688+});
1689+1690+const responses: unknown[] = [];
1691+await registry.gatewayHandlers["explicit-gateway-method.status"]?.({
1692+params: {},
1693+respond: (ok: boolean, payload: unknown, error?: unknown) =>
1694+responses.push({ ok, payload, error }),
1695+} as never);
1696+1697+expect(responses).toEqual([
1698+{ ok: true, payload: { status: "responded" }, error: undefined },
1699+]);
1700+},
1701+},
16231702{
16241703label: "coerces reserved gateway method namespaces to operator.admin",
16251704run: () => {
@@ -2213,8 +2292,8 @@ module.exports = { id: "throws-after-import", register() {} };`,
22132292expect(getGlobalHookRunner()).toBeNull();
22142293},
22152294},
2216-] as const)("handles config-path and scoped plugin loads: $label", ({ run }) => {
2217-run();
2295+] as const)("handles config-path and scoped plugin loads: $label", async ({ run }) => {
2296+await run();
22182297});
2219229822202299it("treats an explicit empty plugin scope as scoped-empty instead of unscoped", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。