Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
refactor(channels): read config from credentials.json5 instead of separate file
Naiyuan Qing112ae6cac964
diff --git a/src/agent/credentials.ts b/src/agent/credentials.tsindex 223798e6ed..5abeca35d1 100644--- a/src/agent/credentials.ts+++ b/src/agent/credentials.ts@@ -31,6 +31,8 @@ export type CredentialsConfig = {order?: Record<string, string[]> | undefined;} | undefined;tools?: Record<string, ToolConfig> | undefined;+ /** Channel plugin configs (telegram, discord, etc.) */+ channels?: Record<string, Record<string, Record<string, unknown>> | undefined> | undefined;};type SkillsEnvConfig = {@@ -217,6 +219,12 @@ export class CredentialManager {);}+ /** Get channel plugin configs from credentials.json5 `channels` section. */+ getChannelsConfig(): Record<string, Record<string, Record<string, unknown>> | undefined> {+ this.loadCore();+ return this.coreConfig?.channels ?? {};+ }+getResolvedEnvSnapshot(): Record<string, string> {return { ...this.getResolvedSkillsEnv() };}diff --git a/src/channels/config.ts b/src/channels/config.tsindex 0d897e68f2..94b49e1e5c 100644--- a/src/channels/config.ts+++ b/src/channels/config.ts@@ -1,30 +1,20 @@/*** Channel configuration loader.*- * Reads ~/.super-multica/channels.json5 for channel credentials and settings.+ * Reads the `channels` section from ~/.super-multica/credentials.json5.*/-import { existsSync, readFileSync } from "node:fs";-import { join } from "node:path";-import JSON5 from "json5";-import { DATA_DIR } from "../shared/paths.js";+import { credentialManager } from "../agent/credentials.js";import type { ChannelsConfig } from "./types.js";-export const CHANNELS_CONFIG_PATH = join(DATA_DIR, "channels.json5");--/** Load channels config from ~/.super-multica/channels.json5 */+/** Load channels config from credentials.json5 `channels` section */export function loadChannelsConfig(): ChannelsConfig {- if (!existsSync(CHANNELS_CONFIG_PATH)) {- console.log(`[Channels] No channels.json5 found, skipping`);- return {};- }- try {- const raw = readFileSync(CHANNELS_CONFIG_PATH, "utf8");- const config = JSON5.parse(raw) as ChannelsConfig;- console.log(`[Channels] Loaded config from ${CHANNELS_CONFIG_PATH}`);- return config;- } catch (err) {- console.warn(`[Channels] Failed to parse ${CHANNELS_CONFIG_PATH}: ${err}`);+ const channels = credentialManager.getChannelsConfig();+ const keys = Object.keys(channels);+ if (keys.length === 0) {+ console.log("[Channels] No channels configured in credentials.json5, skipping");return {};}+ console.log(`[Channels] Loaded config for: ${keys.join(", ")}`);+ return channels;}diff --git a/src/channels/index.ts b/src/channels/index.tsindex 3bbdd20f22..63ecc95040 100644--- a/src/channels/index.ts+++ b/src/channels/index.ts@@ -4,7 +4,7 @@export { ChannelManager } from "./manager.js";export { registerChannel, getChannel, listChannels } from "./registry.js";-export { loadChannelsConfig, CHANNELS_CONFIG_PATH } from "./config.js";+export { loadChannelsConfig } from "./config.js";export type {ChannelPlugin,ChannelMessage,