refactor: rename clawdbot to moltbot with legacy compat
This commit is contained in:
@@ -2,7 +2,7 @@ import type {
|
||||
ChannelOutboundAdapter,
|
||||
ChannelPlugin,
|
||||
ChannelSetupInput,
|
||||
ClawdbotConfig,
|
||||
MoltbotConfig,
|
||||
} from "clawdbot/plugin-sdk";
|
||||
import {
|
||||
applyAccountNameToChannelSection,
|
||||
@@ -30,10 +30,10 @@ type TlonSetupInput = ChannelSetupInput & {
|
||||
};
|
||||
|
||||
function applyTlonSetupConfig(params: {
|
||||
cfg: ClawdbotConfig;
|
||||
cfg: MoltbotConfig;
|
||||
accountId: string;
|
||||
input: TlonSetupInput;
|
||||
}): ClawdbotConfig {
|
||||
}): MoltbotConfig {
|
||||
const { cfg, accountId, input } = params;
|
||||
const useDefault = accountId === DEFAULT_ACCOUNT_ID;
|
||||
const namedConfig = applyAccountNameToChannelSection({
|
||||
@@ -108,7 +108,7 @@ const tlonOutbound: ChannelOutboundAdapter = {
|
||||
return { ok: true, to: parsed.nest };
|
||||
},
|
||||
sendText: async ({ cfg, to, text, accountId, replyToId, threadId }) => {
|
||||
const account = resolveTlonAccount(cfg as ClawdbotConfig, accountId ?? undefined);
|
||||
const account = resolveTlonAccount(cfg as MoltbotConfig, accountId ?? undefined);
|
||||
if (!account.configured || !account.ship || !account.url || !account.code) {
|
||||
throw new Error("Tlon account not configured");
|
||||
}
|
||||
@@ -188,8 +188,8 @@ export const tlonPlugin: ChannelPlugin = {
|
||||
reload: { configPrefixes: ["channels.tlon"] },
|
||||
configSchema: tlonChannelConfigSchema,
|
||||
config: {
|
||||
listAccountIds: (cfg) => listTlonAccountIds(cfg as ClawdbotConfig),
|
||||
resolveAccount: (cfg, accountId) => resolveTlonAccount(cfg as ClawdbotConfig, accountId ?? undefined),
|
||||
listAccountIds: (cfg) => listTlonAccountIds(cfg as MoltbotConfig),
|
||||
resolveAccount: (cfg, accountId) => resolveTlonAccount(cfg as MoltbotConfig, accountId ?? undefined),
|
||||
defaultAccountId: () => "default",
|
||||
setAccountEnabled: ({ cfg, accountId, enabled }) => {
|
||||
const useDefault = !accountId || accountId === "default";
|
||||
@@ -203,7 +203,7 @@ export const tlonPlugin: ChannelPlugin = {
|
||||
enabled,
|
||||
},
|
||||
},
|
||||
} as ClawdbotConfig;
|
||||
} as MoltbotConfig;
|
||||
}
|
||||
return {
|
||||
...cfg,
|
||||
@@ -220,7 +220,7 @@ export const tlonPlugin: ChannelPlugin = {
|
||||
},
|
||||
},
|
||||
},
|
||||
} as ClawdbotConfig;
|
||||
} as MoltbotConfig;
|
||||
},
|
||||
deleteAccount: ({ cfg, accountId }) => {
|
||||
const useDefault = !accountId || accountId === "default";
|
||||
@@ -232,7 +232,7 @@ export const tlonPlugin: ChannelPlugin = {
|
||||
...cfg.channels,
|
||||
tlon: rest,
|
||||
},
|
||||
} as ClawdbotConfig;
|
||||
} as MoltbotConfig;
|
||||
}
|
||||
const { [accountId]: removed, ...remainingAccounts } = cfg.channels?.tlon?.accounts ?? {};
|
||||
return {
|
||||
@@ -244,7 +244,7 @@ export const tlonPlugin: ChannelPlugin = {
|
||||
accounts: remainingAccounts,
|
||||
},
|
||||
},
|
||||
} as ClawdbotConfig;
|
||||
} as MoltbotConfig;
|
||||
},
|
||||
isConfigured: (account) => account.configured,
|
||||
describeAccount: (account) => ({
|
||||
@@ -260,14 +260,14 @@ export const tlonPlugin: ChannelPlugin = {
|
||||
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
|
||||
applyAccountName: ({ cfg, accountId, name }) =>
|
||||
applyAccountNameToChannelSection({
|
||||
cfg: cfg as ClawdbotConfig,
|
||||
cfg: cfg as MoltbotConfig,
|
||||
channelKey: "tlon",
|
||||
accountId,
|
||||
name,
|
||||
}),
|
||||
validateInput: ({ cfg, accountId, input }) => {
|
||||
const setupInput = input as TlonSetupInput;
|
||||
const resolved = resolveTlonAccount(cfg as ClawdbotConfig, accountId ?? undefined);
|
||||
const resolved = resolveTlonAccount(cfg as MoltbotConfig, accountId ?? undefined);
|
||||
const ship = setupInput.ship?.trim() || resolved.ship;
|
||||
const url = setupInput.url?.trim() || resolved.url;
|
||||
const code = setupInput.code?.trim() || resolved.code;
|
||||
@@ -278,7 +278,7 @@ export const tlonPlugin: ChannelPlugin = {
|
||||
},
|
||||
applyAccountConfig: ({ cfg, accountId, input }) =>
|
||||
applyTlonSetupConfig({
|
||||
cfg: cfg as ClawdbotConfig,
|
||||
cfg: cfg as MoltbotConfig,
|
||||
accountId,
|
||||
input: input as TlonSetupInput,
|
||||
}),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { format } from "node:util";
|
||||
|
||||
import type { RuntimeEnv, ReplyPayload, ClawdbotConfig } from "clawdbot/plugin-sdk";
|
||||
import type { RuntimeEnv, ReplyPayload, MoltbotConfig } from "clawdbot/plugin-sdk";
|
||||
|
||||
import { getTlonRuntime } from "../runtime.js";
|
||||
import { resolveTlonAccount } from "../types.js";
|
||||
@@ -31,7 +31,7 @@ type ChannelAuthorization = {
|
||||
};
|
||||
|
||||
function resolveChannelAuthorization(
|
||||
cfg: ClawdbotConfig,
|
||||
cfg: MoltbotConfig,
|
||||
channelNest: string,
|
||||
): { mode: "restricted" | "open"; allowedShips: string[] } {
|
||||
const tlonConfig = cfg.channels?.tlon as
|
||||
@@ -49,7 +49,7 @@ function resolveChannelAuthorization(
|
||||
|
||||
export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<void> {
|
||||
const core = getTlonRuntime();
|
||||
const cfg = core.config.loadConfig() as ClawdbotConfig;
|
||||
const cfg = core.config.loadConfig() as MoltbotConfig;
|
||||
if (cfg.channels?.tlon?.enabled === false) return;
|
||||
|
||||
const logger = core.logging.getChildLogger({ module: "tlon-auto-reply" });
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
|
||||
import { listTlonAccountIds, resolveTlonAccount } from "./types.js";
|
||||
import type { TlonResolvedAccount } from "./types.js";
|
||||
import type { ClawdbotConfig } from "clawdbot/plugin-sdk";
|
||||
import type { MoltbotConfig } from "clawdbot/plugin-sdk";
|
||||
|
||||
const channel = "tlon" as const;
|
||||
|
||||
@@ -18,7 +18,7 @@ function isConfigured(account: TlonResolvedAccount): boolean {
|
||||
}
|
||||
|
||||
function applyAccountConfig(params: {
|
||||
cfg: ClawdbotConfig;
|
||||
cfg: MoltbotConfig;
|
||||
accountId: string;
|
||||
input: {
|
||||
name?: string;
|
||||
@@ -29,7 +29,7 @@ function applyAccountConfig(params: {
|
||||
dmAllowlist?: string[];
|
||||
autoDiscoverChannels?: boolean;
|
||||
};
|
||||
}): ClawdbotConfig {
|
||||
}): MoltbotConfig {
|
||||
const { cfg, accountId, input } = params;
|
||||
const useDefault = accountId === DEFAULT_ACCOUNT_ID;
|
||||
const base = cfg.channels?.tlon ?? {};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ClawdbotConfig } from "clawdbot/plugin-sdk";
|
||||
import type { MoltbotConfig } from "clawdbot/plugin-sdk";
|
||||
|
||||
export type TlonResolvedAccount = {
|
||||
accountId: string;
|
||||
@@ -14,7 +14,7 @@ export type TlonResolvedAccount = {
|
||||
showModelSignature: boolean | null;
|
||||
};
|
||||
|
||||
export function resolveTlonAccount(cfg: ClawdbotConfig, accountId?: string | null): TlonResolvedAccount {
|
||||
export function resolveTlonAccount(cfg: MoltbotConfig, accountId?: string | null): TlonResolvedAccount {
|
||||
const base = cfg.channels?.tlon as
|
||||
| {
|
||||
name?: string;
|
||||
@@ -75,7 +75,7 @@ export function resolveTlonAccount(cfg: ClawdbotConfig, accountId?: string | nul
|
||||
};
|
||||
}
|
||||
|
||||
export function listTlonAccountIds(cfg: ClawdbotConfig): string[] {
|
||||
export function listTlonAccountIds(cfg: MoltbotConfig): string[] {
|
||||
const base = cfg.channels?.tlon as
|
||||
| { ship?: string; accounts?: Record<string, Record<string, unknown>> }
|
||||
| undefined;
|
||||
|
||||
Reference in New Issue
Block a user