@@ -2,11 +2,9 @@ import "./test-helpers.js";
22import fs from "node:fs/promises" ;
33import os from "node:os" ;
44import path from "node:path" ;
5- import { createPinnedLookup } from "openclaw/plugin-sdk/fetch-runtime" ;
6- import { resetInboundDedupe } from "openclaw/plugin-sdk/reply-runtime" ;
7- import { resetLogger , setLoggerOverride } from "openclaw/plugin-sdk/runtime-env" ;
8- import * as ssrf from "openclaw/plugin-sdk/ssrf-runtime" ;
95import { afterAll , afterEach , beforeAll , beforeEach , vi } from "vitest" ;
6+ import { resetInboundDedupe } from "../../../src/auto-reply/reply/inbound-dedupe.js" ;
7+ import { resetLogger , setLoggerOverride } from "../../../src/logging/logger.js" ;
108import type { WebInboundMessage , WebListenerCloseReason } from "./inbound.js" ;
119import {
1210 resetBaileysMocks as _resetBaileysMocks ,
@@ -30,18 +28,19 @@ type MockWebListener = {
3028
3129export const TEST_NET_IP = "203.0.113.10" ;
3230
33- vi . mock ( "openclaw/plugin-sdk/agent-runtime" , async ( importOriginal ) => {
34- const actual = await importOriginal < typeof import ( "openclaw/plugin-sdk/agent-runtime" ) > ( ) ;
35- return {
36- ...actual ,
37- abortEmbeddedPiRun : vi . fn ( ) . mockReturnValue ( false ) ,
38- isEmbeddedPiRunActive : vi . fn ( ) . mockReturnValue ( false ) ,
39- isEmbeddedPiRunStreaming : vi . fn ( ) . mockReturnValue ( false ) ,
40- runEmbeddedPiAgent : vi . fn ( ) ,
41- queueEmbeddedPiMessage : vi . fn ( ) . mockReturnValue ( false ) ,
42- resolveEmbeddedSessionLane : ( key : string ) => `session:${ key . trim ( ) || "main" } ` ,
43- } ;
44- } ) ;
31+ vi . mock ( "openclaw/plugin-sdk/agent-runtime" , ( ) => ( {
32+ abortEmbeddedPiRun : vi . fn ( ) . mockReturnValue ( false ) ,
33+ appendCronStyleCurrentTimeLine : ( text : string ) => text ,
34+ isEmbeddedPiRunActive : vi . fn ( ) . mockReturnValue ( false ) ,
35+ isEmbeddedPiRunStreaming : vi . fn ( ) . mockReturnValue ( false ) ,
36+ queueEmbeddedPiMessage : vi . fn ( ) . mockReturnValue ( false ) ,
37+ resolveEmbeddedSessionLane : ( key : string ) => `session:${ key . trim ( ) || "main" } ` ,
38+ resolveIdentityNamePrefix : ( cfg : { messages ?: { responsePrefix ?: string } } , _agentId : string ) =>
39+ cfg . messages ?. responsePrefix ,
40+ resolveMessagePrefix : ( cfg : { messages ?: { messagePrefix ?: string } } ) =>
41+ cfg . messages ?. messagePrefix ,
42+ runEmbeddedPiAgent : vi . fn ( ) ,
43+ } ) ) ;
4544
4645export async function rmDirWithRetries (
4746 dir : string ,
@@ -132,11 +131,12 @@ export async function makeSessionStore(
132131export function installWebAutoReplyUnitTestHooks ( opts ?: { pinDns ?: boolean } ) {
133132 let resolvePinnedHostnameSpy : { mockRestore : ( ) => unknown } | undefined ;
134133
135- beforeEach ( ( ) => {
134+ beforeEach ( async ( ) => {
136135 vi . clearAllMocks ( ) ;
137136 _resetBaileysMocks ( ) ;
138137 _resetLoadConfigMock ( ) ;
139138 if ( opts ?. pinDns ) {
139+ const ssrf = await import ( "../../../src/infra/net/ssrf.js" ) ;
140140 resolvePinnedHostnameSpy = vi
141141 . spyOn ( ssrf , "resolvePinnedHostname" )
142142 . mockImplementation ( async ( hostname ) => {
@@ -146,7 +146,7 @@ export function installWebAutoReplyUnitTestHooks(opts?: { pinDns?: boolean }) {
146146 return {
147147 hostname : normalized ,
148148 addresses,
149- lookup : createPinnedLookup ( { hostname : normalized , addresses } ) ,
149+ lookup : ssrf . createPinnedLookup ( { hostname : normalized , addresses } ) ,
150150 } ;
151151 } ) ;
152152 }
0 commit comments