@buz-extensions/buz 1.0.0-beta.12 → 1.0.0-beta.13
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/index.ts +21 -14
- package/package.json +1 -1
- package/setup-entry.ts +2 -2
- package/src/inbound.ts +3 -20
package/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { buildChannelConfigSchema } from "openclaw/plugin-sdk/line";
|
|
4
|
-
import { setBuzRuntime } from "./src/inbound.js";
|
|
1
|
+
import { defineChannelPluginEntry } from "openclaw/plugin-sdk/core";
|
|
2
|
+
import type { ChannelPlugin } from "openclaw/plugin-sdk/line";
|
|
3
|
+
import { emptyPluginConfigSchema, buildChannelConfigSchema } from "openclaw/plugin-sdk/line";
|
|
5
4
|
import { z } from "zod";
|
|
6
5
|
|
|
7
6
|
const BuzAccountSchema = z
|
|
@@ -21,6 +20,20 @@ const BuzConfigSchema = z
|
|
|
21
20
|
})
|
|
22
21
|
.partial();
|
|
23
22
|
|
|
23
|
+
// Simple runtime store
|
|
24
|
+
let buzRuntime: any = null;
|
|
25
|
+
|
|
26
|
+
export function setBuzRuntime(runtime: any) {
|
|
27
|
+
buzRuntime = runtime;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getBuzRuntime() {
|
|
31
|
+
if (!buzRuntime) {
|
|
32
|
+
throw new Error("Buz runtime not initialized");
|
|
33
|
+
}
|
|
34
|
+
return buzRuntime;
|
|
35
|
+
}
|
|
36
|
+
|
|
24
37
|
export const buzChannelPlugin = {
|
|
25
38
|
id: "buz",
|
|
26
39
|
meta: {
|
|
@@ -166,17 +179,11 @@ export const buzChannelPlugin = {
|
|
|
166
179
|
},
|
|
167
180
|
} as any;
|
|
168
181
|
|
|
169
|
-
export {
|
|
170
|
-
|
|
171
|
-
const plugin = {
|
|
182
|
+
export default defineChannelPluginEntry({
|
|
172
183
|
id: "buz",
|
|
173
184
|
name: "buz Plugin",
|
|
174
185
|
description: "Connects OpenClaw to buz",
|
|
186
|
+
plugin: buzChannelPlugin as ChannelPlugin,
|
|
175
187
|
configSchema: emptyPluginConfigSchema(),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
api.registerChannel({ plugin: buzChannelPlugin as ChannelPlugin });
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
export default plugin;
|
|
188
|
+
setRuntime: setBuzRuntime,
|
|
189
|
+
});
|
package/package.json
CHANGED
package/setup-entry.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import plugin, { buzChannelPlugin, setBuzRuntime } from "./index.js";
|
|
1
|
+
import plugin, { buzChannelPlugin, setBuzRuntime, getBuzRuntime } from "./index.js";
|
|
2
2
|
|
|
3
|
-
export { buzChannelPlugin, setBuzRuntime } from "./index.js";
|
|
3
|
+
export { buzChannelPlugin, setBuzRuntime, getBuzRuntime } from "./index.js";
|
|
4
4
|
|
|
5
5
|
export default plugin;
|
package/src/inbound.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { recordInboundSessionAndDispatchReply } from "openclaw/plugin-sdk";
|
|
2
2
|
import { sendText } from "./outbound.js";
|
|
3
|
+
import { getBuzRuntime } from "../index.js";
|
|
3
4
|
import { resolve } from "path";
|
|
4
5
|
import { homedir } from "os";
|
|
5
6
|
|
|
@@ -21,20 +22,6 @@ function resolveStorePath(cfg: any): string {
|
|
|
21
22
|
return resolve(homedir(), configuredPath);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
// Simple runtime store without using createPluginRuntimeStore
|
|
25
|
-
let buzRuntime: any = null;
|
|
26
|
-
|
|
27
|
-
export function setBuzRuntime(runtime: any) {
|
|
28
|
-
buzRuntime = runtime;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function getBuzRuntime() {
|
|
32
|
-
if (!buzRuntime) {
|
|
33
|
-
throw new Error("Buz runtime not initialized");
|
|
34
|
-
}
|
|
35
|
-
return buzRuntime;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
25
|
export async function handleInboundMessage(ctx: any, inboundMsg: any) {
|
|
39
26
|
console.log("[buz inbound] =========================================");
|
|
40
27
|
console.log("[buz inbound] handleInboundMessage called");
|
|
@@ -88,13 +75,9 @@ export async function handleInboundMessage(ctx: any, inboundMsg: any) {
|
|
|
88
75
|
try {
|
|
89
76
|
console.log("[buz inbound] dispatching via recordInboundSessionAndDispatchReply...");
|
|
90
77
|
|
|
91
|
-
// Get core from
|
|
92
|
-
const core =
|
|
78
|
+
// Get core from runtime
|
|
79
|
+
const core = getBuzRuntime().core;
|
|
93
80
|
|
|
94
|
-
if (!core) {
|
|
95
|
-
throw new Error("Core runtime not available in context. Make sure runtime is set.");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
81
|
await recordInboundSessionAndDispatchReply({
|
|
99
82
|
recordInboundSession: core.channel.session.recordInboundSession,
|
|
100
83
|
dispatchReplyWithBufferedBlockDispatcher: core.channel.reply.dispatchReplyWithBufferedBlockDispatcher,
|