惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
I
InfoQ
A
About on SuperTechFans
GbyAI
GbyAI
宝玉的分享
宝玉的分享
爱范儿
爱范儿
博客园 - 【当耐特】
博客园 - 司徒正美
博客园 - 聂微东
P
Proofpoint News Feed
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
阮一峰的网络日志
阮一峰的网络日志
B
Blog RSS Feed
Jina AI
Jina AI
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
博客园 - 叶小钗

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor: share Discord account token inspection · opencl...
vincentkoc · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,9 +1,7 @@

11

import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";

2-

import {

3-

hasConfiguredSecretInput,

4-

normalizeSecretInputString,

5-

} from "openclaw/plugin-sdk/secret-input";

2+

import { normalizeSecretInputString } from "openclaw/plugin-sdk/secret-input";

63

import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";

4+

import { inspectDiscordConfiguredToken } from "./account-token-inspect.js";

75

import {

86

mergeDiscordAccountConfig,

97

resolveDefaultDiscordAccountId,

@@ -23,29 +21,6 @@ export type InspectedDiscordAccount = {

2321

config: DiscordAccountConfig;

2422

};

2523
26-

function inspectDiscordTokenValue(value: unknown): {

27-

token: string;

28-

tokenSource: "config";

29-

tokenStatus: Exclude<DiscordCredentialStatus, "missing">;

30-

} | null {

31-

const normalized = normalizeSecretInputString(value);

32-

if (normalized) {

33-

return {

34-

token: normalized.replace(/^Bot\s+/i, ""),

35-

tokenSource: "config",

36-

tokenStatus: "available",

37-

};

38-

}

39-

if (hasConfiguredSecretInput(value)) {

40-

return {

41-

token: "",

42-

tokenSource: "config",

43-

tokenStatus: "configured_unavailable",

44-

};

45-

}

46-

return null;

47-

}

48-
4924

export function inspectDiscordAccount(params: {

5025

cfg: OpenClawConfig;

5126

accountId?: string | null;

@@ -61,7 +36,7 @@ export function inspectDiscordAccount(params: {

6136

accountConfig &&

6237

Object.prototype.hasOwnProperty.call(accountConfig as Record<string, unknown>, "token"),

6338

);

64-

const accountToken = inspectDiscordTokenValue(accountConfig?.token);

39+

const accountToken = inspectDiscordConfiguredToken(accountConfig?.token);

6540

if (accountToken) {

6641

return {

6742

accountId,

@@ -87,7 +62,7 @@ export function inspectDiscordAccount(params: {

8762

};

8863

}

8964
90-

const channelToken = inspectDiscordTokenValue(params.cfg.channels?.discord?.token);

65+

const channelToken = inspectDiscordConfiguredToken(params.cfg.channels?.discord?.token);

9166

if (channelToken) {

9267

return {

9368

accountId,

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,32 @@

1+

import {

2+

hasConfiguredSecretInput,

3+

normalizeSecretInputString,

4+

} from "openclaw/plugin-sdk/secret-input";

5+

import type { DiscordCredentialStatus } from "./token.js";

6+
7+

export type InspectedDiscordConfiguredToken = {

8+

token: string;

9+

tokenSource: "config";

10+

tokenStatus: Exclude<DiscordCredentialStatus, "missing">;

11+

};

12+
13+

export function inspectDiscordConfiguredToken(

14+

value: unknown,

15+

): InspectedDiscordConfiguredToken | null {

16+

const normalized = normalizeSecretInputString(value);

17+

if (normalized) {

18+

return {

19+

token: normalized.replace(/^Bot\s+/i, ""),

20+

tokenSource: "config",

21+

tokenStatus: "available",

22+

};

23+

}

24+

if (hasConfiguredSecretInput(value)) {

25+

return {

26+

token: "",

27+

tokenSource: "config",

28+

tokenStatus: "configured_unavailable",

29+

};

30+

}

31+

return null;

32+

}

Original file line numberDiff line numberDiff line change

@@ -1,10 +1,7 @@

11

import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";

22

import { listCombinedAccountIds } from "openclaw/plugin-sdk/account-resolution";

33

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";

4-

import {

5-

hasConfiguredSecretInput,

6-

normalizeSecretInputString,

7-

} from "openclaw/plugin-sdk/secret-input";

4+

import { inspectDiscordConfiguredToken } from "./account-token-inspect.js";

85

import { resolveDefaultDiscordAccountId } from "./accounts.js";

96

import { mergeDiscordAccountConfig, resolveDiscordAccountConfig } from "./accounts.js";

107

import type { DiscordAccountConfig } from "./runtime-api.js";

@@ -20,29 +17,6 @@ type InspectedDiscordSetupAccount = {

2017

config: DiscordAccountConfig;

2118

};

2219
23-

function inspectConfiguredToken(value: unknown): {

24-

token: string;

25-

tokenSource: "config";

26-

tokenStatus: "available" | "configured_unavailable";

27-

} | null {

28-

const normalized = normalizeSecretInputString(value);

29-

if (normalized) {

30-

return {

31-

token: normalized.replace(/^Bot\s+/i, ""),

32-

tokenSource: "config",

33-

tokenStatus: "available",

34-

};

35-

}

36-

if (hasConfiguredSecretInput(value)) {

37-

return {

38-

token: "",

39-

tokenSource: "config",

40-

tokenStatus: "configured_unavailable",

41-

};

42-

}

43-

return null;

44-

}

45-
4620

export function listDiscordSetupAccountIds(cfg: OpenClawConfig): string[] {

4721

const accounts = cfg.channels?.discord?.accounts;

4822

return listCombinedAccountIds({

@@ -82,7 +56,7 @@ export function inspectDiscordSetupAccount(params: {

8256

accountConfig &&

8357

Object.prototype.hasOwnProperty.call(accountConfig as Record<string, unknown>, "token"),

8458

);

85-

const accountToken = inspectConfiguredToken(accountConfig?.token);

59+

const accountToken = inspectDiscordConfiguredToken(accountConfig?.token);

8660

if (accountToken) {

8761

return {

8862

accountId,

@@ -106,7 +80,7 @@ export function inspectDiscordSetupAccount(params: {

10680

};

10781

}

10882
109-

const channelToken = inspectConfiguredToken(params.cfg.channels?.discord?.token);

83+

const channelToken = inspectDiscordConfiguredToken(params.cfg.channels?.discord?.token);

11084

if (channelToken) {

11185

return {

11286

accountId,