@@ -4,14 +4,41 @@ import { tryReadSecretFileSync } from "openclaw/plugin-sdk/channel-core";
44import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime" ;
55import type { TelegramAccountConfig } from "openclaw/plugin-sdk/config-runtime" ;
66import { DEFAULT_ACCOUNT_ID , normalizeAccountId } from "openclaw/plugin-sdk/routing" ;
7- import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input" ;
7+ import {
8+ normalizeSecretInputString ,
9+ resolveSecretInputString ,
10+ } from "openclaw/plugin-sdk/secret-input" ;
811
912export type TelegramTokenSource = "env" | "tokenFile" | "config" | "none" ;
1013
1114export type TelegramTokenResolution = BaseTokenResolution & {
1215 source : TelegramTokenSource ;
1316} ;
1417
18+ function resolveRuntimeTokenValue ( params : { value : unknown ; path : string } ) : string | undefined {
19+ const resolved = resolveSecretInputString ( {
20+ value : params . value ,
21+ path : params . path ,
22+ mode : "inspect" ,
23+ } ) ;
24+ if ( resolved . status === "available" ) {
25+ return resolved . value ;
26+ }
27+ if ( resolved . status !== "configured_unavailable" ) {
28+ return undefined ;
29+ }
30+ if ( resolved . ref . source === "env" ) {
31+ return normalizeSecretInputString ( process . env [ resolved . ref . id ] ) ;
32+ }
33+ // Runtime resolution stays strict for non-env SecretRefs.
34+ resolveSecretInputString ( {
35+ value : params . value ,
36+ path : params . path ,
37+ mode : "strict" ,
38+ } ) ;
39+ return undefined ;
40+ }
41+
1542type ResolveTelegramTokenOpts = {
1643 envToken ?: string | null ;
1744 accountId ?: string | null ;
@@ -79,7 +106,7 @@ export function resolveTelegramToken(
79106 return { token : "" , source : "none" } ;
80107 }
81108
82- const accountToken = normalizeResolvedSecretInputString ( {
109+ const accountToken = resolveRuntimeTokenValue ( {
83110 value : accountCfg ?. botToken ,
84111 path : `channels.telegram.accounts.${ accountId } .botToken` ,
85112 } ) ;
@@ -100,7 +127,7 @@ export function resolveTelegramToken(
100127 return { token : "" , source : "none" } ;
101128 }
102129
103- const configToken = normalizeResolvedSecretInputString ( {
130+ const configToken = resolveRuntimeTokenValue ( {
104131 value : telegramCfg ?. botToken ,
105132 path : "channels.telegram.botToken" ,
106133 } ) ;
0 commit comments