mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 19:01:47 +03:00
refactor: rename to openclaw
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
formatPairingApproveHint,
|
||||
type ChannelPlugin,
|
||||
} from "clawdbot/plugin-sdk";
|
||||
} from "openclaw/plugin-sdk";
|
||||
|
||||
import { NostrConfigSchema } from "./config-schema.js";
|
||||
import { getNostrRuntime } from "./runtime.js";
|
||||
@@ -221,7 +221,7 @@ export const nostrPlugin: ChannelPlugin<ResolvedNostrAccount> = {
|
||||
onMessage: async (senderPubkey, text, reply) => {
|
||||
ctx.log?.debug(`[${account.accountId}] DM from ${senderPubkey}: ${text.slice(0, 50)}...`);
|
||||
|
||||
// Forward to moltbot's message pipeline
|
||||
// Forward to OpenClaw's message pipeline
|
||||
await runtime.channel.reply.handleInboundMessage({
|
||||
channel: "nostr",
|
||||
accountId: account.accountId,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MarkdownConfigSchema, buildChannelConfigSchema } from "clawdbot/plugin-sdk";
|
||||
import { MarkdownConfigSchema, buildChannelConfigSchema } from "openclaw/plugin-sdk";
|
||||
import { z } from "zod";
|
||||
|
||||
const allowFromEntry = z.union([z.string(), z.number()]);
|
||||
|
||||
@@ -3,7 +3,7 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { PluginRuntime } from "clawdbot/plugin-sdk";
|
||||
import type { PluginRuntime } from "openclaw/plugin-sdk";
|
||||
|
||||
import {
|
||||
readNostrBusState,
|
||||
@@ -13,23 +13,24 @@ import {
|
||||
import { setNostrRuntime } from "./runtime.js";
|
||||
|
||||
async function withTempStateDir<T>(fn: (dir: string) => Promise<T>) {
|
||||
const previous = process.env.CLAWDBOT_STATE_DIR;
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-nostr-"));
|
||||
process.env.CLAWDBOT_STATE_DIR = dir;
|
||||
const previous = process.env.OPENCLAW_STATE_DIR;
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-nostr-"));
|
||||
process.env.OPENCLAW_STATE_DIR = dir;
|
||||
setNostrRuntime({
|
||||
state: {
|
||||
resolveStateDir: (env, homedir) => {
|
||||
const override = env.CLAWDBOT_STATE_DIR?.trim();
|
||||
const override =
|
||||
env.OPENCLAW_STATE_DIR?.trim() || env.OPENCLAW_STATE_DIR?.trim();
|
||||
if (override) return override;
|
||||
return path.join(homedir(), ".clawdbot");
|
||||
return path.join(homedir(), ".openclaw");
|
||||
},
|
||||
},
|
||||
} as PluginRuntime);
|
||||
try {
|
||||
return await fn(dir);
|
||||
} finally {
|
||||
if (previous === undefined) delete process.env.CLAWDBOT_STATE_DIR;
|
||||
else process.env.CLAWDBOT_STATE_DIR = previous;
|
||||
if (previous === undefined) delete process.env.OPENCLAW_STATE_DIR;
|
||||
else process.env.OPENCLAW_STATE_DIR = previous;
|
||||
await fs.rm(dir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PluginRuntime } from "clawdbot/plugin-sdk";
|
||||
import type { PluginRuntime } from "openclaw/plugin-sdk";
|
||||
|
||||
let runtime: PluginRuntime | null = null;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MoltbotConfig } from "clawdbot/plugin-sdk";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk";
|
||||
import { getPublicKeyFromPrivate } from "./nostr-bus.js";
|
||||
import { DEFAULT_RELAYS } from "./nostr-bus.js";
|
||||
import type { NostrProfile } from "./config-schema.js";
|
||||
@@ -30,7 +30,7 @@ const DEFAULT_ACCOUNT_ID = "default";
|
||||
/**
|
||||
* List all configured Nostr account IDs
|
||||
*/
|
||||
export function listNostrAccountIds(cfg: MoltbotConfig): string[] {
|
||||
export function listNostrAccountIds(cfg: OpenClawConfig): string[] {
|
||||
const nostrCfg = (cfg.channels as Record<string, unknown> | undefined)?.nostr as
|
||||
| NostrAccountConfig
|
||||
| undefined;
|
||||
@@ -46,7 +46,7 @@ export function listNostrAccountIds(cfg: MoltbotConfig): string[] {
|
||||
/**
|
||||
* Get the default account ID
|
||||
*/
|
||||
export function resolveDefaultNostrAccountId(cfg: MoltbotConfig): string {
|
||||
export function resolveDefaultNostrAccountId(cfg: OpenClawConfig): string {
|
||||
const ids = listNostrAccountIds(cfg);
|
||||
if (ids.includes(DEFAULT_ACCOUNT_ID)) return DEFAULT_ACCOUNT_ID;
|
||||
return ids[0] ?? DEFAULT_ACCOUNT_ID;
|
||||
@@ -56,7 +56,7 @@ export function resolveDefaultNostrAccountId(cfg: MoltbotConfig): string {
|
||||
* Resolve a Nostr account from config
|
||||
*/
|
||||
export function resolveNostrAccount(opts: {
|
||||
cfg: MoltbotConfig;
|
||||
cfg: OpenClawConfig;
|
||||
accountId?: string | null;
|
||||
}): ResolvedNostrAccount {
|
||||
const accountId = opts.accountId ?? DEFAULT_ACCOUNT_ID;
|
||||
|
||||
Reference in New Issue
Block a user