@@ -5719,6 +5719,74 @@ describe("verifySetupInference", () => {
57195719 } ) ;
57205720 } ) ;
57215721
5722+ it ( "binds Claude native login when a retired profile remains in the store" , async ( ) => {
5723+ const authProfileId = "anthropic:claude-cli" ;
5724+ const config = {
5725+ agents : { defaults : { model : "claude-cli/claude-opus-5" } } ,
5726+ } satisfies OpenClawConfig ;
5727+ const profiles = {
5728+ [ authProfileId ] : {
5729+ type : "oauth" as const ,
5730+ provider : "claude-cli" ,
5731+ access : "retired-access" ,
5732+ refresh : "retired-refresh" ,
5733+ expires : Date . now ( ) - 60_000 ,
5734+ } ,
5735+ } ;
5736+ const nativeRuntimeOwner = "native-claude-runtime-owner" ;
5737+ const resolveCliRuntimeOwnerFingerprint = vi . fn ( async ( params : { authProfileId ?: string } ) =>
5738+ params . authProfileId ? "retired-profile-owner" : nativeRuntimeOwner ,
5739+ ) ;
5740+ const runCliAgent = vi . fn (
5741+ async ( params : {
5742+ authProfileId ?: string ;
5743+ onSuccessfulAuthBinding ?: ( binding : AgentExecutionAuthBinding ) => void ;
5744+ } ) => {
5745+ params . onSuccessfulAuthBinding ?.( {
5746+ runtimeOwnerFingerprint : nativeRuntimeOwner ,
5747+ runtimeOwnerKind : "cli-runtime" ,
5748+ runtimeOwnerId : "claude-cli" ,
5749+ runtimeArtifactFingerprint : testCliRuntimeArtifactFingerprint ,
5750+ runtimeArtifactId : "claude-cli" ,
5751+ } ) ;
5752+ return {
5753+ meta : {
5754+ finalAssistantVisibleText : "OK" ,
5755+ executionTrace : {
5756+ winnerProvider : "claude-cli" ,
5757+ winnerModel : "claude-opus-5" ,
5758+ } ,
5759+ } ,
5760+ } ;
5761+ } ,
5762+ ) ;
5763+
5764+ const result = await verifySetupInference ( {
5765+ bindSession : true ,
5766+ deps : {
5767+ readConfigFileSnapshot : vi . fn ( async ( ) => ( { exists : true , valid : true , config } ) ) as never ,
5768+ loadAuthProfileStoreForRuntime : vi . fn ( ( ) => ( { version : 1 , profiles } ) ) as never ,
5769+ ensureAuthProfileStore : vi . fn ( ( ) => ( { version : 1 , profiles } ) ) as never ,
5770+ createSystemAgentVerifiedInferenceBinding,
5771+ resolveCliRuntimeArtifactFingerprint : vi . fn ( async ( ) => testCliRuntimeArtifactFingerprint ) ,
5772+ resolveCliRuntimeOwnerFingerprint : resolveCliRuntimeOwnerFingerprint as never ,
5773+ runCliAgent : runCliAgent as never ,
5774+ } ,
5775+ } ) ;
5776+
5777+ expect ( result ) . toMatchObject ( {
5778+ ok : true ,
5779+ binding : {
5780+ auth : { authFingerprint : nativeRuntimeOwner , proofKind : "runtime-owner" } ,
5781+ execution : { provider : "claude-cli" , model : "claude-opus-5" } ,
5782+ } ,
5783+ } ) ;
5784+ expect ( runCliAgent ) . toHaveBeenCalledOnce ( ) ;
5785+ expect ( runCliAgent . mock . calls [ 0 ] ?. [ 0 ] . authProfileId ) . toBeUndefined ( ) ;
5786+ expect ( resolveCliRuntimeOwnerFingerprint ) . toHaveBeenCalledOnce ( ) ;
5787+ expect ( resolveCliRuntimeOwnerFingerprint . mock . calls [ 0 ] ?. [ 0 ] . authProfileId ) . toBeUndefined ( ) ;
5788+ } ) ;
5789+
57225790 it ( "rejects an owner plugin replacement during the live inference turn" , async ( ) => {
57235791 const profileId = "openai:verified" ;
57245792 const credential = {
0 commit comments