66 * only need to change their import path.
77 */
88
9- import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot" ;
109import {
1110 containerCheck ,
1211 containerRpcRequest ,
@@ -28,6 +27,8 @@ export type SignalSseEvent = {
2827 data ?: string ;
2928} ;
3029
30+ export type SignalApiMode = "native" | "container" | "auto" ;
31+
3132// Re-export the options type so consumers can import it from the adapter.
3233export type { SignalRpcOptions } from "./client.js" ;
3334
@@ -37,8 +38,7 @@ const detectedModeCache = new Map<
3738 { mode : "native" | "container" ; expiresAt : number ; receiveAccount ?: string }
3839> ( ) ;
3940
40- function getConfiguredApiMode ( ) : "native" | "container" | "auto" {
41- const configured = getRuntimeConfig ( ) . channels ?. signal ?. apiMode ;
41+ function resolveConfiguredApiMode ( configured ?: SignalApiMode ) : SignalApiMode {
4242 if ( configured === "native" || configured === "container" ) {
4343 return configured ;
4444 }
@@ -87,8 +87,9 @@ async function resolveApiModeForOperation(params: {
8787 account ?: string ;
8888 requireContainerReceive ?: boolean ;
8989 timeoutMs ?: number ;
90+ apiMode ?: SignalApiMode ;
9091} ) : Promise < "native" | "container" > {
91- const configured = getConfiguredApiMode ( ) ;
92+ const configured = resolveConfiguredApiMode ( params . apiMode ) ;
9293
9394 if ( configured === "native" || configured === "container" ) {
9495 return configured ;
@@ -137,13 +138,14 @@ export async function detectSignalApiMode(
137138export async function signalRpcRequest < T = unknown > (
138139 method : string ,
139140 params : Record < string , unknown > | undefined ,
140- opts : SignalRpcOptions & { accountId ?: string } ,
141+ opts : SignalRpcOptions & { accountId ?: string ; apiMode ?: SignalApiMode } ,
141142) : Promise < T > {
142143 const mode = await resolveApiModeForOperation ( {
143144 baseUrl : opts . baseUrl ,
144145 accountId : opts . accountId ,
145146 account : typeof params ?. account === "string" ? params . account : undefined ,
146147 timeoutMs : opts . timeoutMs ,
148+ apiMode : opts . apiMode ,
147149 } ) ;
148150 if ( mode === "native" ) {
149151 return nativeRpcRequest < T > ( method , params , opts ) ;
@@ -157,8 +159,9 @@ export async function signalRpcRequest<T = unknown>(
157159export async function signalCheck (
158160 baseUrl : string ,
159161 timeoutMs = DEFAULT_TIMEOUT_MS ,
162+ options : { apiMode ?: SignalApiMode } = { } ,
160163) : Promise < { ok : boolean ; status ?: number | null ; error ?: string | null } > {
161- const configured = getConfiguredApiMode ( ) ;
164+ const configured = resolveConfiguredApiMode ( options . apiMode ) ;
162165 const mode =
163166 configured === "auto"
164167 ? await resolveAutoApiMode ( baseUrl , timeoutMs ) . catch ( ( error : unknown ) => {
@@ -186,13 +189,15 @@ export async function streamSignalEvents(params: {
186189 timeoutMs ?: number ;
187190 onEvent : ( event : SignalSseEvent ) => void ;
188191 logger ?: { log ?: ( msg : string ) => void ; error ?: ( msg : string ) => void } ;
192+ apiMode ?: SignalApiMode ;
189193} ) : Promise < void > {
190194 const mode = await resolveApiModeForOperation ( {
191195 baseUrl : params . baseUrl ,
192196 accountId : params . accountId ,
193197 account : params . account ,
194198 requireContainerReceive : true ,
195199 timeoutMs : resolveAutoProbeTimeoutMs ( params . timeoutMs ) ,
200+ apiMode : params . apiMode ,
196201 } ) ;
197202
198203 if ( mode === "container" ) {
@@ -227,12 +232,14 @@ export async function fetchAttachment(params: {
227232 groupId ?: string ;
228233 timeoutMs ?: number ;
229234 maxResponseBytes ?: number ;
235+ apiMode ?: SignalApiMode ;
230236} ) : Promise < Buffer | null > {
231237 const mode = await resolveApiModeForOperation ( {
232238 baseUrl : params . baseUrl ,
233239 accountId : params . accountId ,
234240 account : params . account ,
235241 timeoutMs : params . timeoutMs ,
242+ apiMode : params . apiMode ,
236243 } ) ;
237244 if ( mode === "container" ) {
238245 return containerFetchAttachment ( params . attachmentId , {
0 commit comments