mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-17 06:11:01 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
94
openclaw/extensions/nostr/index.ts
Normal file
94
openclaw/extensions/nostr/index.ts
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
import {
|
||||
defineBundledChannelEntry,
|
||||
loadBundledEntryExportSync,
|
||||
} from "openclaw/plugin-sdk/channel-entry-contract";
|
||||
import type { PluginRuntime, ResolvedNostrAccount } from "./api.js";
|
||||
|
||||
function createNostrProfileHttpHandler() {
|
||||
return loadBundledEntryExportSync<
|
||||
(params: Record<string, unknown>) => (ctx: unknown) => Promise<void> | void
|
||||
>(import.meta.url, {
|
||||
specifier: "./api.js",
|
||||
exportName: "createNostrProfileHttpHandler",
|
||||
});
|
||||
}
|
||||
|
||||
function getNostrRuntime() {
|
||||
return loadBundledEntryExportSync<() => PluginRuntime>(import.meta.url, {
|
||||
specifier: "./api.js",
|
||||
exportName: "getNostrRuntime",
|
||||
})();
|
||||
}
|
||||
|
||||
function resolveNostrAccount(params: { cfg: unknown; accountId: string }) {
|
||||
return loadBundledEntryExportSync<
|
||||
(params: { cfg: unknown; accountId: string }) => ResolvedNostrAccount
|
||||
>(import.meta.url, {
|
||||
specifier: "./api.js",
|
||||
exportName: "resolveNostrAccount",
|
||||
})(params);
|
||||
}
|
||||
|
||||
export default defineBundledChannelEntry({
|
||||
id: "nostr",
|
||||
name: "Nostr",
|
||||
description: "Nostr DM channel plugin via NIP-04",
|
||||
importMetaUrl: import.meta.url,
|
||||
plugin: {
|
||||
specifier: "./api.js",
|
||||
exportName: "nostrPlugin",
|
||||
},
|
||||
runtime: {
|
||||
specifier: "./api.js",
|
||||
exportName: "setNostrRuntime",
|
||||
},
|
||||
registerFull(api) {
|
||||
const httpHandler = createNostrProfileHttpHandler()({
|
||||
getConfigProfile: (accountId: string) => {
|
||||
const runtime = getNostrRuntime();
|
||||
const cfg = runtime.config.loadConfig();
|
||||
const account = resolveNostrAccount({ cfg, accountId });
|
||||
return account.profile;
|
||||
},
|
||||
updateConfigProfile: async (accountId: string, profile: unknown) => {
|
||||
const runtime = getNostrRuntime();
|
||||
const cfg = runtime.config.loadConfig();
|
||||
|
||||
const channels = (cfg.channels ?? {}) as Record<string, unknown>;
|
||||
const nostrConfig = (channels.nostr ?? {}) as Record<string, unknown>;
|
||||
|
||||
await runtime.config.writeConfigFile({
|
||||
...cfg,
|
||||
channels: {
|
||||
...channels,
|
||||
nostr: {
|
||||
...nostrConfig,
|
||||
profile,
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
getAccountInfo: (accountId: string) => {
|
||||
const runtime = getNostrRuntime();
|
||||
const cfg = runtime.config.loadConfig();
|
||||
const account = resolveNostrAccount({ cfg, accountId });
|
||||
if (!account.configured || !account.publicKey) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
pubkey: account.publicKey,
|
||||
relays: account.relays,
|
||||
};
|
||||
},
|
||||
log: api.logger,
|
||||
});
|
||||
|
||||
api.registerHttpRoute({
|
||||
path: "/api/channels/nostr",
|
||||
auth: "gateway",
|
||||
match: "prefix",
|
||||
gatewayRuntimeScopeSurface: "trusted-operator",
|
||||
handler: httpHandler,
|
||||
});
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue