@buz-extensions/buz 1.0.0-beta.10 → 1.0.0-beta.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ChannelPlugin, OpenClawPluginApi } from "openclaw/plugin-sdk/line";
2
2
  import { emptyPluginConfigSchema } from "openclaw/plugin-sdk/line";
3
3
  import { buildChannelConfigSchema } from "openclaw/plugin-sdk/line";
4
- import { setBuzRuntime } from "./src/runtime.js";
4
+ import { setBuzRuntime } from "./src/inbound.js";
5
5
  import { z } from "zod";
6
6
 
7
7
  const BuzAccountSchema = z
@@ -88,12 +88,10 @@ export const buzChannelPlugin = {
88
88
  setup: {
89
89
  validateInput: async (params: any) => {
90
90
  const { setupAdapter } = await import("./src/setup.js");
91
- // Returns string (error message) or null (valid)
92
91
  return setupAdapter.validateInput(params);
93
92
  },
94
93
  applyAccountConfig: async (params: any) => {
95
94
  const { setupAdapter } = await import("./src/setup.js");
96
- // Returns OpenClawConfig directly
97
95
  const newCfg = await setupAdapter.applyAccountConfig(params);
98
96
  return newCfg;
99
97
  },
@@ -168,7 +166,7 @@ export const buzChannelPlugin = {
168
166
  },
169
167
  } as any;
170
168
 
171
- export { setBuzRuntime } from "./src/runtime.js";
169
+ export { setBuzRuntime } from "./src/inbound.js";
172
170
 
173
171
  const plugin = {
174
172
  id: "buz",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buz-extensions/buz",
3
- "version": "1.0.0-beta.10",
3
+ "version": "1.0.0-beta.11",
4
4
  "description": "OpenClaw buz channel plugin",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/inbound.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { recordInboundSessionAndDispatchReply } from "openclaw/plugin-sdk";
2
2
  import { sendText } from "./outbound.js";
3
- import { getBuzRuntime } from "./runtime.js";
4
3
  import { resolve } from "path";
5
4
  import { homedir } from "os";
6
5
 
@@ -16,14 +15,26 @@ function resolveDefaultAgentIdCompat(cfg: any): string {
16
15
 
17
16
  function resolveStorePath(cfg: any): string {
18
17
  const configuredPath = cfg?.session?.storePath || ".openclaw/sessions";
19
- // If it's already an absolute path, use it as-is
20
18
  if (configuredPath.startsWith("/") || configuredPath.startsWith("~")) {
21
19
  return configuredPath.replace(/^~/, homedir());
22
20
  }
23
- // Otherwise, resolve relative to home directory
24
21
  return resolve(homedir(), configuredPath);
25
22
  }
26
23
 
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
+
27
38
  export async function handleInboundMessage(ctx: any, inboundMsg: any) {
28
39
  console.log("[buz inbound] =========================================");
29
40
  console.log("[buz inbound] handleInboundMessage called");
@@ -77,9 +88,13 @@ export async function handleInboundMessage(ctx: any, inboundMsg: any) {
77
88
  try {
78
89
  console.log("[buz inbound] dispatching via recordInboundSessionAndDispatchReply...");
79
90
 
80
- // Get core from runtime
81
- const core = getBuzRuntime().core;
91
+ // Get core from ctx.runtime or global runtime
92
+ const core = ctx.runtime?.core || buzRuntime?.core;
82
93
 
94
+ if (!core) {
95
+ throw new Error("Core runtime not available in context. Make sure runtime is set.");
96
+ }
97
+
83
98
  await recordInboundSessionAndDispatchReply({
84
99
  recordInboundSession: core.channel.session.recordInboundSession,
85
100
  dispatchReplyWithBufferedBlockDispatcher: core.channel.reply.dispatchReplyWithBufferedBlockDispatcher,
package/src/runtime.ts DELETED
@@ -1,7 +0,0 @@
1
- import { createPluginRuntimeStore } from "openclaw/plugin-sdk";
2
- import type { PluginRuntime } from "openclaw/plugin-sdk";
3
-
4
- const { setRuntime: setBuzRuntime, getRuntime: getBuzRuntime } =
5
- createPluginRuntimeStore<PluginRuntime>("Buz runtime not initialized");
6
-
7
- export { getBuzRuntime, setBuzRuntime };